Skip to content
Snippets Groups Projects
Commit c0c3ac5e authored by Megan Henning's avatar Megan Henning
Browse files

Fix terms search, more info on error

parent 20a508d1
No related branches found
No related tags found
No related merge requests found
import copy
import json
from elasticsearch import ElasticsearchException, TransportError, helpers
from elasticsearch import ElasticsearchException, TransportError, RequestError, helpers
from ..web import base
from .. import config
......@@ -372,6 +372,10 @@ class DataExplorerHandler(base.RequestHandler):
else:
modified_filters.append({'terms': {k+'.raw': v}})
elif f.get('term'):
# Search raw field
for k,v in f['term'].iteritems():
modified_filters.append({'term': {k+'.raw': v}})
else:
modified_filters.append(f)
......@@ -687,11 +691,14 @@ class DataExplorerHandler(base.RequestHandler):
## RUNNING QUERIES AND PROCESSING RESULTS ##
def _run_query(self, es_query, result_type):
results = config.es.search(
index='data_explorer',
doc_type='flywheel',
body=es_query
)
try:
results = config.es.search(
index='data_explorer',
doc_type='flywheel',
body=es_query
)
except RequestError as e:
self.abort(400, 'Unable to parse filters - invalid format.')
return self._process_results(results, result_type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment