You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2019/06/11 00:57:52 UTC
[kibble] 02/02: Delete differently depending on ES version
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git
commit 20377b5109625b550ad99a8df992256c8643c60c
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Jun 11 02:57:37 2019 +0200
Delete differently depending on ES version
---
api/pages/sources.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/api/pages/sources.py b/api/pages/sources.py
index 46583a8..792fbe0 100644
--- a/api/pages/sources.py
+++ b/api/pages/sources.py
@@ -266,7 +266,12 @@ def run(API, environ, indata, session):
sourceID = indata.get('id')
if session.DB.ES.exists(index=session.DB.dbname, doc_type="source", id = sourceID):
# Delete all data pertainig to this source
- session.DB.ES.delete_by_query(index=session.DB.dbname, body = {'query': {'match': {'sourceID': sourceID}}})
+ # For ES >= 6.x, use a glob for removing from all indices
+ if session.DB.ESversion > 5:
+ session.DB.ES.delete_by_query(index=session.DB.dbname+'_*', body = {'query': {'match': {'sourceID': sourceID}}})
+ else:
+ # For ES <= 5.x, just remove from the main index
+ session.DB.ES.delete_by_query(index=session.DB.dbname, body = {'query': {'match': {'sourceID': sourceID}}})
# Delete the object itself
session.DB.ES.delete(index=session.DB.dbname, doc_type="source", id = sourceID)
yield json.dumps({'message': "Source deleted"})