Skip to content

Commit

Permalink
[Issue #2775] Opportunity number partial match fix (#2777)
Browse files Browse the repository at this point in the history
## Summary
Fixes #2775 

### Time to review: __5 mins__

## Changes proposed
Adjusts the fields we query against and how in search

## Context for reviewers
I wrote up a pretty thorough explanation of keyword vs non-keyword on
#2775 - check that out. In short, the bug here is due to how the
request/field being compared are tokenized. Keyword leaves a field
"whole" and non-keyword tokenizes it into pieces. In the case of
opportunity number splitting on each of the dashes (so `ABC-123-XYZ`
becomes `["ABC", "123", "XYZ"]`. In short, to support all the ways
someone might want to query for an opportunity number, it's easiest to
just include both.

## Additional information
Some testing locally where I set the opportunity number to
`FY25-BSB-56789` and `FY25-BSB-12345` for two opportunities:

<img width="1262" alt="Screenshot 2024-11-07 at 2 27 07 PM"
src="https://github.com/user-attachments/assets/cec4140d-5c74-4797-a6e4-67682e6035d8">
<img width="1209" alt="Screenshot 2024-11-07 at 2 27 12 PM"
src="https://github.com/user-attachments/assets/aeda447f-8ec8-430a-807f-2a3f1ac4681f">
<img width="1219" alt="Screenshot 2024-11-07 at 2 27 18 PM"
src="https://github.com/user-attachments/assets/0d5235b5-cfd8-4697-a97a-43c3c098deb7">
<img width="1231" alt="Screenshot 2024-11-07 at 2 27 31 PM"
src="https://github.com/user-attachments/assets/1d6746b8-baf9-4cc5-8f49-51e95eb9410e">
  • Loading branch information
chouinar authored Nov 12, 2024
1 parent ad988c4 commit 22ccd25
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/src/services/opportunities_v1/experimental_constant.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
from enum import StrEnum

DEFAULT = [
# Note that we do keyword for agency & opportunity number
# Note that we do keyword & non-keyword for agency & opportunity number
# as we don't want to compare to a tokenized value which
# may have split on the dashes.
# may have split on the dashes, but also still support prefixing (eg. USAID-*)
"agency^16",
"agency.keyword^16",
"opportunity_title^2",
"opportunity_number^12",
"opportunity_number.keyword^12",
"summary.summary_description",
"opportunity_assistance_listings.assistance_listing_number^10",
"opportunity_assistance_listings.program_title^4",
]

EXPANDED = [
"agency",
"agency.keyword",
"agency_name",
"top_level_agency_name",
"opportunity_title",
"opportunity_number",
"opportunity_number.keyword",
"category_explanation",
"summary.summary_description",
Expand All @@ -28,6 +32,7 @@


AGENCY = [
"agency",
"agency.keyword",
"agency_name",
"top_level_agency_name",
Expand Down

0 comments on commit 22ccd25

Please sign in to comment.