meilisearch/document.go

52 lines
1.1 KiB
Go
Raw Permalink Normal View History

2022-10-27 03:03:35 +00:00
package meilisearch
import "git.selly.red/Selly-Modules/logger"
2022-11-14 03:12:55 +00:00
func (i *Index) AddDocuments(docs interface{}) error {
2022-10-27 03:03:35 +00:00
_, 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
}
2022-11-15 02:57:02 +00:00
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
}
2022-11-14 03:12:55 +00:00
func (i *Index) DeleteDocumentsByPrimaryKeys(keys []string) error {
2022-10-27 03:03:35 +00:00
_, 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
}