From b4e3b6b92845ae45439f8e0c0f3d471a9ce6fa02 Mon Sep 17 00:00:00 2001 From: Ramy Asselin Date: Wed, 9 Dec 2015 14:22:48 -0800 Subject: [PATCH] Add support for extra elastic-search graph filter Add the ability to add custom elastic-search query suffix. This is useful to better support use cases that limit searches to e.g. specific branches. Change-Id: Iaf28003d7a2a09e3134ed5f75c602b694efb51c6 --- elastic_recheck/cmd/graph.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/elastic_recheck/cmd/graph.py b/elastic_recheck/cmd/graph.py index a00ac3da..47b0dcb7 100755 --- a/elastic_recheck/cmd/graph.py +++ b/elastic_recheck/cmd/graph.py @@ -103,6 +103,14 @@ def main(): help='output filename. Omit for stdout') parser.add_argument('-q', dest='queue', help='limit results to a build queue regex') + parser.add_argument('--es-query-suffix', + help='further limit results with an ' + 'elastic search query suffix. This will be ANDed ' + 'to all queries. ' + 'For example, to limit all queries to a ' + 'specific branch use: ' + ' --es-query-suffix "build_branch:\\"stable/' + 'liberty\\""') parser.add_argument('-c', '--conf', help="Elastic Recheck Configuration " "file to use for data_source options such as " "elastic search url, logstash url, and database " @@ -153,8 +161,10 @@ def main(): for query in classifier.queries: if args.queue: - query['query'] = query['query'] + (' AND build_queue:%s' % - args.queue) + query['query'] += ' AND build_queue:%s' % args.queue + if args.es_query_suffix: + query['query'] += ' AND (%s)' % args.es_query_suffix + if query.get('suppress-graph'): continue if args.verbose: