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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsIndex
value. If the request was sucessful orError
if a failure occured. -
List all indexes.
Declaration
Swift
public static func getAll(config: Config, _ completion: @escaping (Result<[Indexes], Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[Index]
value. If the request was sucessful orError
if 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
uid
The unique identifier for the
Index
to be created.primaryKey
the unique field of a document.
completion
The completion closure used to notify when the server completes the write request, it returns a
Result
object that containsIndex
value. If the request was sucessful orError
if 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
uid
The unique identifier for the
Index
to be created.primaryKey
the unique field of a document.
completion
The completion closure used to notify when the server completes the write request, it returns a
Result
object that containsIndex
value. If the request was sucessful orError
if a failure occured. -
Update the index primaryKey.
Declaration
Swift
public func update( primaryKey: String, _ completion: @escaping (Result<Indexes, Swift.Error>) -> Void)
Parameters
primaryKey
the unique field of a document.
completion
The completion closure used to notify when the server completes the update request, it returns a
Result
object that contains()
value. If the request was sucessful orError
if a failure occured. -
Delete the index.
Declaration
Swift
public func delete( _ completion: @escaping (Result<(), Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the delete request, it returns a
Result
object that contains()
value. If the request was sucessful orError
if a failure occured. -
Delete the index only if it exists.
Declaration
Swift
public func deleteIfExists(_ completion: @escaping (Bool) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the delete request, it returns a
Bool
that istrue
If the request sucessfully deleted an existent index orfalse
if 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: Encodable
Parameters
documents
The documents to add in MeiliSearch.
Encoder
The data structure of your documents.
primaryKey
The primary key of a document.
completion
The completion closure used to notify when the server completes the update request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
documents
The document data (JSON) to be processed.
primaryKey
The primary key of a document.
completion
The completion closure used to notify when the server completes the update request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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,
addDocuments
Declaration
Swift
public func updateDocuments<T>( documents: [T], encoder: JSONEncoder? = nil, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void) where T: Encodable
Parameters
documents
The documents to update in MeiliSearch.
Encoder
The data structure of your documents.
primaryKey
The primary key of a document.
completion
The completion closure used to notify when the server completes the update request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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,
addDocuments
Declaration
Swift
public func updateDocuments( documents: Data, primaryKey: String? = nil, _ completion: @escaping (Result<Update, Swift.Error>) -> Void)
Parameters
documents
The document data (JSON) to be processed.
primaryKey
The primary key of a document.
completion
The completion closure used to notify when the server completes the update request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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: Equatable
Parameters
identifier
The document identifier for the document to be found.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsT
value. If the request was sucessful orError
if 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: Equatable
Parameters
identifier
The document identifier for the document to be found.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsT
value. If the request was sucessful orError
if 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: Equatable
Parameters
options
Options on get documents.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[T]
value. If the request was sucessful orError
if 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
documentId
The document identifier of the document.
completion
The completion closure used to notify when the server completes the delete request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if a failure occured. -
Delete all Documents on the index.
Declaration
Swift
public func deleteAllDocuments( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the delete request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
documentIds
The array of unique identifier for the document to be deleted.
completion
The completion closure used to notify when the server completes the delete request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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: Equatable
Parameters
searchParameters
Options on search.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsSearchResult<T>
value. If the request was sucessful orError
if 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
updateId
The update identifier.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsKey
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsKey
value. If the request was sucessful orError
if 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
updateId
The id of the update.
completion
The 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsSetting
value. If the request was sucessful orError
if a failure occured. -
Update the settings of the index.
Declaration
Parameters
setting
Settings to change.
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if a failure occured. -
Reset the settings of the index.
Declaration
Swift
public func resetSettings( _ completion: @escaping (Result<Update, Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String: [String]]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if a failure occured.
-
Get the distinct attribute field of an
Index
.Declaration
Swift
public func getDistinctAttribute( _ completion: @escaping (Result<String?, Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if a failure occured.
-
Get the searchable attribute field of an
Index
.Declaration
Swift
public func getSearchableAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if a failure occured.
-
Get the displayed attribute field of the index.
Declaration
Swift
public func getDisplayedAttributes( _ completion: @escaping (Result<[String], Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains[String]
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value. If the request was sucessful orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains an[String]
value if the request was successful, orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value if the request was successful, orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that contains an[String]
value if the request was successful, orError
if 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
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsUpdate
value if the request was successful, orError
if a failure occurred.
-
Get stats of the index.
Declaration
Swift
public func stats( _ completion: @escaping (Result<Stat, Swift.Error>) -> Void)
Parameters
completion
The completion closure used to notify when the server completes the query request, it returns a
Result
object that containsStat
value. If the request was sucessful orError
if a failure occured.