@@ -183,9 +183,9 @@ def serialize_os_agg_collection_bucket(bucket: dict):
183183 volume = id [5 :9 ]
184184 return {'id' : id , 'journal' : journal , 'volume' : volume , 'pages' : bucket ['doc_count' ]}
185185
186- def serialize_os_collection_result (result : dict , page : int , limit : int , contentQuery ):
186+ def serialize_os_collection_result (result : dict , page : int , limit : int , contentQuery , agg_bucket_limit : int = 10000 ):
187187 total_count = result ['aggregations' ]['total_count' ]['value' ]
188- page_count = int (math .ceil (total_count / limit ))
188+ page_count = int (math .ceil (min ( total_count , agg_bucket_limit ) / limit ))
189189 es_buckets = result ['aggregations' ]['ids' ]['buckets' ]
190190
191191 return {'page' : page , 'pageCount' : page_count , 'limit' : limit , 'total' : total_count , 'query' : contentQuery ,
@@ -195,9 +195,9 @@ def serialize_os_agg_article_bucket(bucket: dict):
195195 id = bucket ['key' ]
196196 return {'id' : id , 'bibcode' : id , 'pages' : bucket ['doc_count' ]}
197197
198- def serialize_os_article_result (result : dict , page : int , limit : int , contentQuery = '' , extra_col_count = 0 , extra_page_count = 0 ):
198+ def serialize_os_article_result (result : dict , page : int , limit : int , contentQuery = '' , extra_col_count = 0 , extra_page_count = 0 , agg_bucket_limit : int = 10000 ):
199199 total_count = result ['aggregations' ]['total_count' ]['value' ]
200- page_count = int (math .ceil (total_count / limit ))
200+ page_count = int (math .ceil (min ( total_count , agg_bucket_limit ) / limit ))
201201 es_buckets = result ['aggregations' ]['ids' ]['buckets' ]
202202
203203 return {'page' : page , 'pageCount' : page_count , 'limit' : limit , 'total' : total_count , 'query' : contentQuery ,
0 commit comments