Indexes
public struct Indexes
Undocumented
-
The index uid.
Declaration
Swift
public let uid: String -
The data when the index was created.
Declaration
Swift
public let createdAt: Date? -
The data when the index was last updated.
Declaration
Swift
public let updatedAt: Date? -
The primary key configured for the index.
Declaration
Swift
public let primaryKey: String?
-
Get the index.
Declaration
Swift
public func get(_ completion: @escaping (Result<Indexes, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsIndexvalue. If the request was sucessful orErrorif a failure occured. -
List all indexes.
Declaration
Swift
public static func getAll(config: Config, _ completion: @escaping (Result<[Indexes], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[Index]value. If the request was sucessful orErrorif a failure occured. -
Get or create an index.
Declaration
Swift
public static func getOrCreate( uid: String, primaryKey: String? = nil, config: Config, _ completion: @escaping (Result<Indexes, Swift.Error>) -> Void)Parameters
uidThe unique identifier for the
Indexto be created.primaryKeythe unique field of a document.
completionThe completion closure used to notify when the server completes the write request, it returns a
Resultobject that containsIndexvalue. If the request was sucessful orErrorif a failure occured. -
Create a new Index for the given
uid.Declaration
Swift
public static func create( uid: String, primaryKey: String? = nil, config: Config, _ completion: @escaping (Result<Indexes, Swift.Error>) -> Void)Parameters
uidThe unique identifier for the
Indexto be created.primaryKeythe unique field of a document.
completionThe completion closure used to notify when the server completes the write request, it returns a
Resultobject that containsIndexvalue. If the request was sucessful orErrorif a failure occured. -
Update the index primaryKey.
Declaration
Swift
public func update( primaryKey: String, _ completion: @escaping (Result<Indexes, Swift.Error>) -> Void)Parameters
primaryKeythe unique field of a document.
completionThe completion closure used to notify when the server completes the update request, it returns a
Resultobject that contains()value. If the request was sucessful orErrorif a failure occured. -
Delete the index.
Declaration
Swift
public func delete( _ completion: @escaping (Result<(), Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the delete request, it returns a
Resultobject that contains()value. If the request was sucessful orErrorif a failure occured. -
Delete the index only if it exists.
Declaration
Swift
public func deleteIfExists(_ completion: @escaping (Bool) -> Void)Parameters
completionThe completion closure used to notify when the server completes the delete request, it returns a
Boolthat istrueIf the request sucessfully deleted an existent index orfalseif a failure occured or the index do not exist.
-
Add a list of documents or replace them if they already exist.
If you send an already existing document (same id) the whole existing document will be overwritten by the new document. Fields previously in the document not present in the new document are removed.
For a partial update of the document see
updateDocuments.Declaration
Swift
public func addDocuments<T>( documents: [T], encoder: JSONEncoder? = nil, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) where T: EncodableParameters
documentsThe documents to add in MeiliSearch.
EncoderThe data structure of your documents.
primaryKeyThe primary key of a document.
completionThe completion closure used to notify when the server completes the update request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Add a list of documents as data or replace them if they already exist.
If you send an already existing document (same id) the whole existing document will be overwritten by the new document. Fields previously in the document not present in the new document are removed.
For a partial update of the document see
updateDocuments.Declaration
Swift
public func addDocuments( documents: Data, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
documentsThe document data (JSON) to be processed.
primaryKeyThe primary key of a document.
completionThe completion closure used to notify when the server completes the update request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Add a list of documents or update them if they already exist. If the provided index does not exist, it will be created.
If you send an already existing document (same documentId) the old document will be only partially updated according to the fields of the new document. Thus, any fields not present in the new document are kept and remained unchanged.
To completely overwrite a document,
addDocumentsDeclaration
Swift
public func updateDocuments<T>( documents: [T], encoder: JSONEncoder? = nil, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) where T: EncodableParameters
documentsThe documents to update in MeiliSearch.
EncoderThe data structure of your documents.
primaryKeyThe primary key of a document.
completionThe completion closure used to notify when the server completes the update request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Add a list of documents or update them if they already exist. If the provided index does not exist, it will be created.
If you send an already existing document (same documentId) the old document will be only partially updated according to the fields of the new document. Thus, any fields not present in the new document are kept and remained unchanged.
To completely overwrite a document,
addDocumentsDeclaration
Swift
public func updateDocuments( documents: Data, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
documentsThe document data (JSON) to be processed.
primaryKeyThe primary key of a document.
completionThe completion closure used to notify when the server completes the update request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Get the document on the index based on the provided document identifier.
Declaration
Swift
public func getDocument<T>( _ identifier: String, _ completion: @escaping (Result<T, Swift.Error>) -> Void) where T: Codable, T: EquatableParameters
identifierThe document identifier for the document to be found.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsTvalue. If the request was sucessful orErrorif a failure occured. -
Get the document on the index based on the provided document identifier.
Declaration
Swift
public func getDocument<T>( _ identifier: Int, _ completion: @escaping (Result<T, Swift.Error>) -> Void) where T: Codable, T: EquatableParameters
identifierThe document identifier for the document to be found.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsTvalue. If the request was sucessful orErrorif a failure occured. -
List all Documents.
Declaration
Swift
public func getDocuments<T>( options: GetParameters? = nil, _ completion: @escaping (Result<[T], Swift.Error>) -> Void) where T: Codable, T: EquatableParameters
optionsOptions on get documents.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[T]value. If the request was sucessful orErrorif a failure occured. -
Delete a document on the index based on the provided document identifier.
Declaration
Swift
public func deleteDocument( _ documentId: String, _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
documentIdThe document identifier of the document.
completionThe completion closure used to notify when the server completes the delete request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Delete all Documents on the index.
Declaration
Swift
public func deleteAllDocuments( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the delete request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Delete a selection of documents based on array of document
identifiers‘s.Declaration
Swift
public func deleteBatchDocuments( _ documentIds: [Int], _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
documentIdsThe array of unique identifier for the document to be deleted.
completionThe completion closure used to notify when the server completes the delete request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Search in the index.
Declaration
Swift
public func search<T>( _ searchParameters: SearchParameters, _ completion: @escaping (Result<SearchResult<T>, Swift.Error>) -> Void) where T: Codable, T: EquatableParameters
searchParametersOptions on search.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsSearchResult<T>value. If the request was sucessful orErrorif a failure occured.
-
Get the status of an update of the index.
Declaration
Swift
public func getUpdate( _ updateId: Int, _ completion: @escaping (Result<Update.Result, Swift.Error>) -> Void)Parameters
updateIdThe update identifier.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsKeyvalue. If the request was sucessful orErrorif a failure occured. -
Get the status of an update of the index.
Declaration
Swift
public func getAllUpdates( _ completion: @escaping (Result<[Update.Result], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsKeyvalue. If the request was sucessful orErrorif a failure occured. -
Wait for an update to be processed or failed.
Providing an update id, returned by asynchronous MeiliSearch options, call are made to MeiliSearch to check if the update has been processed or if it has failed.
Declaration
Swift
public func waitForPendingUpdate( update: Update, options: WaitOptions? = nil, _ completion: @escaping (Result<Update.Result, Swift.Error> ) -> Void)Parameters
updateIdThe id of the update.
completionThe completion closure used to notify when the server
-
Get a list of all the customization possible of the index.
Declaration
Swift
public func getSettings( _ completion: @escaping (Result<SettingResult, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsSettingvalue. If the request was sucessful orErrorif a failure occured. -
Update the settings of the index.
Declaration
Parameters
settingSettings to change.
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured. -
Reset the settings of the index.
Declaration
Swift
public func resetSettings( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get a list of all synonyms possible of the index.
Declaration
Swift
public func getSynonyms( _ completion: @escaping (Result<[String: [String]], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String: [String]]value. If the request was sucessful orErrorif a failure occured. -
Update the synonyms of the index.
Declaration
Swift
public func updateSynonyms( _ synonyms: [String: [String]]?, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the synonyms of the index.
Declaration
Swift
public func resetSynonyms( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get a list of all stop-words possible of the index.
Declaration
Swift
public func getStopWords( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String]value. If the request was sucessful orErrorif a failure occured. -
Update the stop-words of the index.
Declaration
Swift
public func updateStopWords( _ stopWords: [String]?, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the stop-words of the index.
Declaration
Swift
public func resetStopWords( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get a list of all ranking rules possible of the index.
Declaration
Swift
public func getRankingRules( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String]value. If the request was sucessful orErrorif a failure occured. -
Update the ranking rules of the index.
Declaration
Swift
public func updateRankingRules( _ rankingRules: [String], _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the ranking rules of the index.
Declaration
Swift
public func resetRankingRules( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get the distinct attribute field of an
Index.Declaration
Swift
public func getDistinctAttribute( _ completion: @escaping (Result<String?, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String]value. If the request was sucessful orErrorif a failure occured. -
Update the distinct attribute field of the index.
Declaration
Swift
public func updateDistinctAttribute( _ distinctAttribute: String, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the distinct attribute field of the index.
Declaration
Swift
public func resetDistinctAttribute( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get the searchable attribute field of an
Index.Declaration
Swift
public func getSearchableAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String]value. If the request was sucessful orErrorif a failure occured. -
Update the searchable attribute field of the index.
Declaration
Swift
public func updateSearchableAttributes( _ searchableAttribute: [String], _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the searchable attribute field of the index.
Declaration
Swift
public func resetSearchableAttributes( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get the displayed attribute field of the index.
Declaration
Swift
public func getDisplayedAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains[String]value. If the request was sucessful orErrorif a failure occured. -
Update the displayed attribute field of the index.
Declaration
Swift
public func updateDisplayedAttributes( _ displayedAttribute: [String], _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the displayed attribute field of the index.
Declaration
Swift
public func resetDisplayedAttributes( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue. If the request was sucessful orErrorif a failure occured.
-
Get the attributes that are filterable of the index.
Declaration
Swift
public func getFilterableAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains an[String]value if the request was successful, orErrorif a failure occurred. -
Update the attributes that are filterable of the index.
Declaration
Swift
public func updateFilterableAttributes( _ attributes: [String], _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the attributes that are filterable of the index.
Declaration
Swift
public func resetFilterableAttributes( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue if the request was successful, orErrorif a failure occurred.
-
Get the attributes that are sortable of the index.
Declaration
Swift
public func getSortableAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that contains an[String]value if the request was successful, orErrorif a failure occurred. -
Update the attributes that are sortable of the index.
Declaration
Swift
public func updateSortableAttributes( _ attributes: [String], _ completion: @escaping (Result<Update, Swift.Error>) -> Void) -
Reset the attributes that are sortable of the index.
Declaration
Swift
public func resetSortableAttributes( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsUpdatevalue if the request was successful, orErrorif a failure occurred.
-
Get stats of the index.
Declaration
Swift
public func stats( _ completion: @escaping (Result<Stat, Swift.Error>) -> Void)Parameters
completionThe completion closure used to notify when the server completes the query request, it returns a
Resultobject that containsStatvalue. If the request was sucessful orErrorif a failure occured.
Indexes Structure Reference