Commit a587a1ea authored by ale's avatar ale

add back search

parent cba64792
......@@ -151,8 +151,7 @@ class LogStore(object):
self.conn.deleteByQuery(q)
self.conn.optimize(self.INDEX)
def scan(self, query_str, time_range):
log.info('search: "%s"', query_str)
def _make_search(self, query_str, time_range):
query = pyes.query.StringQuery(query_str)
if time_range:
trange = pyes.utils.ESRange(
......@@ -164,6 +163,17 @@ class LogStore(object):
search = pyes.query.Search(query, track_scores=False, size=100,
sort={'timestamp': 'asc'})
return search
def search(self, query_str, time_range):
log.info('search: "%s"', query_str)
search = self._make_search(query_str, time_range)
results = self.conn.search(search)
return [x['_source'] for x in results['hits']['hits']]
def scan(self, query_str, time_range):
log.info('scan: "%s"', query_str)
search = self._make_search(query_str, time_range)
results = self.conn.scan(search)
for batch in results:
for doc in batch['hits']['hits']:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment