Skip to content

Commit

Permalink
fix: adding back total count as there will be only 1 doc
Browse files Browse the repository at this point in the history
  • Loading branch information
wphyojpl committed Jan 16, 2025
1 parent 7154fc9 commit 681a388
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions cumulus_lambda_functions/lib/uds_db/granules_db_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ def add_entry(self, tenant: str, tenant_venue: str, json_body: dict, doc_id: str
LOGGER.debug(f'custom_metadata indexed')
return

def get_size(self, tenant: str, tenant_venue: str, search_dsl: dict):
read_alias_name = f'{DBConstants.granules_read_alias_prefix}_{tenant}_{tenant_venue}'.lower().strip()
search_dsl['size'] = 0
search_dsl['track_total_hits'] = True
search_result = self.__es.query(search_dsl, querying_index=read_alias_name)
result_size = self.__es.get_result_size(search_result)
return result_size

def dsl_search(self, tenant: str, tenant_venue: str, search_dsl: dict):
read_alias_name = f'{DBConstants.granules_read_alias_prefix}_{tenant}_{tenant_venue}'.lower().strip()
if 'sort' not in search_dsl: # We cannot paginate w/o sort. So, max is 10k items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __generate_es_dsl(self):
if self.__filter_input is not None:
query_terms.append(CqlParser('properties').transform(self.__filter_input))
query_dsl = {
'track_total_hits': False,
'track_total_hits': self.__offset is None,
'size': self.__limit,
# "collapse": {"field": "id"},
'sort': [
Expand Down Expand Up @@ -232,7 +232,7 @@ def start(self):
return {
'statusCode': 200,
'body': {
'numberMatched': {'total_size': result_size},
'numberMatched': {'total_size': -1 if self.__offset is not None else result_size},
'numberReturned': len(granules_query_result['hits']['hits']),
'stac_version': '1.0.0',
'type': 'FeatureCollection', # TODO correct name?
Expand Down

0 comments on commit 681a388

Please sign in to comment.