def _get_query(self, req): """Get elastic query.""" args = getattr(req, "args", {}) source = json.loads(args.get("source")) if args.get("source") else { "query": { "filtered": {} } } try: self._enhance_query_string( source["query"]["filtered"]["query"]["query_string"]) except KeyError: pass if app.data.elastic.should_aggregate(req): source["aggs"] = self.aggregations if app.data.elastic.should_highlight(req): highlight_query = get_elastic_highlight_query( self._get_highlight_query_string(req)) if highlight_query: source["highlight"] = highlight_query return source
def _get_query(self, req): """Get elastic query.""" args = getattr(req, 'args', {}) query = json.loads(args.get('source')) if args.get('source') else {'query': {'filtered': {}}} if app.data.elastic.should_aggregate(req): query['aggs'] = self.aggregations if app.data.elastic.should_highlight(req): highlight_query = get_elastic_highlight_query(self._get_highlight_query_string(req)) if highlight_query: query['highlight'] = highlight_query return query
def _get_query(self, req): """Get elastic query.""" args = getattr(req, 'args', {}) query = json.loads(args.get('source')) if args.get('source') else {'query': {'filtered': {}}} if app.data.elastic.should_aggregate(req): query['aggs'] = aggregations if app.data.elastic.should_highlight(req): highlight_query = get_elastic_highlight_query(self._get_highlight_query_string(req)) if highlight_query: query['highlight'] = highlight_query return query
def _get_query(self, req): """Get elastic query.""" args = getattr(req, "args", {}) query = json.loads(args.get("source")) if args.get("source") else { "query": { "filtered": {} } } if app.data.elastic.should_aggregate(req): query["aggs"] = self.aggregations if app.data.elastic.should_highlight(req): highlight_query = get_elastic_highlight_query( self._get_highlight_query_string(req)) if highlight_query: query["highlight"] = highlight_query return query