Implement deleting database matches

This commit is contained in:
2023-02-09 21:17:50 +00:00
parent 9a8bb9027f
commit c67d89c978
2 changed files with 34 additions and 2 deletions

View File

@@ -79,6 +79,21 @@ class ElasticsearchBackend(StorageBackend):
index=settings.INDEX_RULE_STORAGE, mappings=mapping["mappings"]
)
def delete_rule_entries(self, rule_id):
"""
Delete all entries for a given rule.
:param rule_id: The rule ID to delete.
"""
if self.client is None:
self.initialise()
search_query = self.construct_query(None, None, blank=True)
search_query["query"]["bool"]["must"].append(
{"match_phrase": {"rule_id": rule_id}}
)
return self.client.delete_by_query(
index=settings.INDEX_RULE_STORAGE, body=search_query
)
def construct_context_query(
self, index, net, channel, src, num, size, type=None, nicks=None
):