Documentation ¶
Index ¶
- type IndexAttributeItem
- type IndexConfigs
- type Logger
- type MSearch
- func (ms *MSearch) AddDoc(indexName string, docPtr any) error
- func (ms *MSearch) ApplyIndexConfigs(configData []byte) error
- func (ms *MSearch) DelDoc(indexName string, docId string) error
- func (ms *MSearch) DeleteAllDocuments(indexName string) error
- func (ms *MSearch) GetDoc(indexName string, docId string, bindResult any) (bool, error)
- func (ms *MSearch) Search(indexName string, query string, options *meilisearch.SearchRequest) *meilisearch.SearchResponse
- func (ms *MSearch) UpdateDoc(indexName string, docPtr any) error
- func (ms *MSearch) WaitForTaskSuccess(taskUID int64) error
- type SortOrder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IndexAttributeItem ¶
type IndexConfigs ¶
type IndexConfigs struct {
ConfigData *configDataMap `json:"config_data"`
}
type MSearch ¶
type MSearch struct {
// contains filtered or unexported fields
}
func (*MSearch) AddDoc ¶
AddDoc is a method that adds a document to the index specified by indexName. The docPtr parameter must be a pointer, otherwise an error will be returned. The method first checks if the docPtr is a pointer using reflection. If the check fails, an error is returned. Otherwise, the method calls the AddDocuments function on the corresponding index through the Meilisearch client. If there's an error during the AddDocuments call, the error is returned. Finally, the method calls WaitForTaskSuccess to wait for the task to complete, using the TaskUID from the response of the AddDocuments call. If the wait is successful, the method returns nil.
Note: This method depends on the MSearch.WaitForTaskSuccess method for waiting for the task to complete. Please refer to the documentation of that method for more details.
func (*MSearch) ApplyIndexConfigs ¶
func (*MSearch) DelDoc ¶
DelDoc is a method that deletes a document with the specified docId from the index with the specified indexName. It makes a call to the MeiliSearch Index DeleteDocument() method using the client. It returns an error if an error occurs while deleting the document, otherwise it waits for the delete task to complete using the WaitForTaskSuccess() method and returns any error that occurs during waiting. The WaitForTaskSuccess() method waits for a task with a specified taskUID to complete. It polls for the status of the task every 50 milliseconds, increasing the wait time for the next check by doubling it, up to a maximum delay of 1 second. This is done to limit the number of calls to the GetTask function when the task takes a significant amount of time to complete.
func (*MSearch) DeleteAllDocuments ¶ added in v0.2.0
DeleteAllDocuments is a method that deletes all documents in the specified index.
func (*MSearch) Search ¶
func (ms *MSearch) Search(indexName string, query string, options *meilisearch.SearchRequest) *meilisearch.SearchResponse
Search is a method that performs a search query on the specified index with the given query and options. It returns a *meilisearch.SearchResponse containing the search results. If there's an error occurring while performing the search query, it will log the error and return nil.
func (*MSearch) UpdateDoc ¶
UpdateDoc is a method that updates a document in the specified index with the given data. It first checks if the docPtr is a pointer and returns an error if it is not. It then calls the UpdateDocuments function of the client's Index with the docPtr. If there's an error during the update process, it returns the error. Finally, it calls WaitForTaskSuccess with the TaskUID from the response, to wait for the update task to complete.underlying concrete type
func (*MSearch) WaitForTaskSuccess ¶
WaitForTaskSuccess is a method that waits for a task with a specified taskUID to complete. It will return an error either if there's an error occurring while getting the task detail from the client or when the context deadline is exceeded (after 20 seconds).
This function starts by polling for the status of the task every 50 milliseconds, and every time the task status is retrieved, the wait time for the next check is doubled, up to a maximum delay of 1 second. This is done to limit the number of calls to the GetTask function, especially in cases where the task takes a significant amount of time to complete.