52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package meilisearch
|
|
|
|
import "git.selly.red/Selly-Modules/logger"
|
|
|
|
func (i *Index) AddDocuments(docs interface{}) error {
|
|
_, err := getIndex(i.Name).AddDocuments(docs)
|
|
if err != nil {
|
|
logger.Error("add documents", logger.LogData{
|
|
Source: "meilisearch.index.AddDocuments",
|
|
Message: err.Error(),
|
|
Data: logger.Map{
|
|
"index": i,
|
|
"docs": docs,
|
|
},
|
|
})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (i *Index) UpdateDocuments(docs interface{}) error {
|
|
_, err := getIndex(i.Name).UpdateDocuments(docs)
|
|
if err != nil {
|
|
logger.Error("update documents", logger.LogData{
|
|
Source: "meilisearch.index.UpdateDocuments",
|
|
Message: err.Error(),
|
|
Data: logger.Map{
|
|
"index": i,
|
|
"docs": docs,
|
|
},
|
|
})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (i *Index) DeleteDocumentsByPrimaryKeys(keys []string) error {
|
|
_, err := getIndex(i.Name).DeleteDocuments(keys)
|
|
if err != nil {
|
|
logger.Error("delete documents", logger.LogData{
|
|
Source: "meilisearch.index.DeleteDocumentsByPrimaryKeys",
|
|
Message: err.Error(),
|
|
Data: logger.Map{
|
|
"index": i,
|
|
"keys": keys,
|
|
},
|
|
})
|
|
}
|
|
|
|
return err
|
|
}
|