Skip to content

Commit

Permalink
pagination for get_protein_ko_count
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed Dec 24, 2019
1 parent 75ab30b commit 8e66ac6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions datanator_query_python/query/full_text_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ def get_protein_ko_count(self, q, num, **kwargs):
"""Get protein index with different ko_number field for up to num hits.
Args:
q (:obj:`str`): query message
num (:obj:`int`): number of hits needed
q (:obj:`str`): query message.
num (:obj:`int`): number of hits needed.
**from_ (:obj:`int`): starting offset (default: 0).
Return:
(:obj:`dict`): obj of index hits {'index': []}
Expand Down Expand Up @@ -195,7 +196,8 @@ def get_protein_ko_count(self, q, num, **kwargs):
body = self.build_bool_query_body(must=must, must_not=must_not)
body['aggs'] = aggregation
body['size'] = 0
r = self.build_es().search(index=index, body=body, size=num)
from_ = kwargs.get('from_', 0)
r = self.build_es().search(index=index, body=body, size=num, from_=from_)
return r['aggregations']
# hits = r['hits']['hits']
# if hits == []:
Expand Down

0 comments on commit 8e66ac6

Please sign in to comment.