Skip to content

Commit

Permalink
[Issue 3498] exclude attachments from search response (#3531)
Browse files Browse the repository at this point in the history
## Summary
Fixes #{[3498](#3498)}

### Time to review: __5 mins__

## Changes proposed
Modified the search method of our opensearch client to pass through an
optional excludes param
Modified our search API to set the attachments field to be excluded

---------

Co-authored-by: nava-platform-bot <[email protected]>
  • Loading branch information
babebe and nava-platform-bot authored Jan 16, 2025
1 parent 9a99264 commit c9c2e5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion api/src/adapters/search/opensearch_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,14 @@ def search(
search_query: dict,
include_scores: bool = True,
params: dict | None = None,
excludes: list[str] | None = None,
) -> SearchResponse:
if params is None:
params = {}

response = self._client.search(index=index_name, body=search_query, params=params)
response = self._client.search(
index=index_name, body=search_query, params=params, _source_excludes=excludes
)
return SearchResponse.from_opensearch_response(response, include_scores)

def scroll(
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/opportunities_v1/search_opportunities.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def search_opportunities(
"Querying search index alias %s", index_alias, extra={"search_index_alias": index_alias}
)

response = search_client.search(index_alias, search_request)
response = search_client.search(index_alias, search_request, excludes=["attachments"])

pagination_info = PaginationInfo(
page_offset=search_params.pagination.page_offset,
Expand Down

0 comments on commit c9c2e5c

Please sign in to comment.