From db51054c645475de3f7c2b4e6eb283a8fed0231e Mon Sep 17 00:00:00 2001 From: Michael Chouinard Date: Thu, 16 May 2024 11:24:30 -0400 Subject: [PATCH] Just a few updates to the query box --- api/src/adapters/opensearch/populate_search_index.py | 1 - .../services/opportunities_v0_1/search_opportunities.py | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/api/src/adapters/opensearch/populate_search_index.py b/api/src/adapters/opensearch/populate_search_index.py index cae4c0e0c..6c9f58ed3 100644 --- a/api/src/adapters/opensearch/populate_search_index.py +++ b/api/src/adapters/opensearch/populate_search_index.py @@ -46,7 +46,6 @@ def insert(opensearch_client: OpenSearch, db_session: db.Session) -> None: continue body = OpportunitySchema().dump(opp) - print(body) # TODO - use the bulk endpoint instead # however that requires making raw JSON text - which I'll do later diff --git a/api/src/services/opportunities_v0_1/search_opportunities.py b/api/src/services/opportunities_v0_1/search_opportunities.py index 4bb517fb2..c6eef2fd2 100644 --- a/api/src/services/opportunities_v0_1/search_opportunities.py +++ b/api/src/services/opportunities_v0_1/search_opportunities.py @@ -214,11 +214,10 @@ def opensearch_approach(search_params: SearchOpportunityParams) -> Tuple[Sequenc if search_params.query: must_filters.append({ - "multi_match": { + "simple_query_string": { "query": search_params.query, - "fields": ["agency^16", "opportunity_title^2", "opportunity_number^12", "summary.summary_description", "opportunity_assistance_listings.assistance_listing_number^10", "opportunity_assistance_listings.program_title^4"], - "type": "best_fields", - "tie_breaker": 0.3 + "default_operator": "AND", + "fields": ["agency.keyword^16", "opportunity_title^2", "opportunity_number^12", "summary.summary_description", "opportunity_assistance_listings.assistance_listing_number^10", "opportunity_assistance_listings.program_title^4"], } } ) @@ -254,8 +253,8 @@ def opensearch_approach(search_params: SearchOpportunityParams) -> Tuple[Sequenc if non_scoring_filters: body["query"]["bool"]["filter"] = non_scoring_filters + print(body) result = client.search(body=body, index="test-opportunity-index") - print(result) raw_opps = [opp for opp in result["hits"]["hits"]]