TP-5555 | clean up job

This commit is contained in:
varnit goyal
2024-12-10 13:24:49 +05:30
parent 17a707633e
commit eda34db8fc
6 changed files with 69 additions and 65 deletions

View File

@@ -45,6 +45,13 @@ func (el *ElasticSearchClient) IndexDocument(document interface{}) {
}
}
func (el *ElasticSearchClient) DeleteDocuments(searchRequest string) {
_, err := el.client.DeleteByQuery(el.Config.Index).Raw(strings.NewReader(searchRequest)).Do(context.TODO())
if err != nil {
log.Printf("unable to delete documents: %s", err.Error())
}
log.Printf("successfully deleted documents: %s", searchRequest)
}
func (el *ElasticSearchClient) SearchDocuments(searchRequest string, fields []string) ([]map[string]interface{}, map[string]interface{}, int64, error) {
res, err := el.client.Search().
Index(el.Config.Index).Raw(strings.NewReader(searchRequest)).