-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fuzzy-date function to case search #35065
Conversation
@esoergel No tests or documentation yet. But I was curious about your thoughts on this? I was think about adding a third parameter to let you specify a range in years for how far the permutations could be away from the original date. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks great, and the profiling results so far sound quite promising
Co-authored-by: Ethan Soergel <[email protected]>
Use should query with two clauses: 1) terms for all permutations and 2) term for just the orignal date will give cases with an exact date match a higher score.
@@ -233,7 +233,7 @@ def multiplex_to_adapter(domain): | |||
return None | |||
|
|||
|
|||
def case_property_query(case_property_name, value, fuzzy=False, multivalue_mode=None): | |||
def case_property_query(case_property_name, value, fuzzy=False, multivalue_mode=None, boost_first=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@esoergel I am feeling a bit iffy about adding yet another flag here. I see two alternatives:
- just create a separate function
case_property_query_boost_first
and call it fromfuzzy_date
- use
_base_property_query
directly infuzzy_date
probably renaming it without the underscore in the process.
I am curious, if you have a preference?
Should be formatted correctly beforehand though
"2042-03-21", | ||
"2042-12-30" | ||
], boost_first=True) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Know you're still working on this. Have you thought about adding a test that validates the output of the query is as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AddisonDunn is there a test the run ES queries against test data already? I am having trouble finding any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests in test_case_search_filters
test that a query in a case search function returns the cases expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AddisonDunn pushed the test
7b834fb
to
75e7234
Compare
{'_id': 'c1', 'dob': date(2020, 3, 1)}, | ||
{'_id': 'c2', 'dob': date(2020, 1, 3)}, | ||
{'_id': 'c3', 'dob': date(2002, 3, 1)}, | ||
{'_id': 'c4', 'dob': date(2020, 3, 4)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
self.assertItemsEqual( | ||
query.get_ids(), | ||
output | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think other tests put the xpath query as part of a call to get_case_search_query
under the query
. Kind of silly though IMO I think it basically does the same thing
@@ -435,6 +436,21 @@ def test_fuzzy_case_property_query(self): | |||
['c3'] | |||
) | |||
|
|||
def test_fuzzy_date(self): | |||
print("############## test_fuzzy_date") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this print statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not.
cdc50b9
to
e28bbfc
Compare
Product Description
Add a function to fuzzy search dates.
Technical Summary
https://dimagi.atlassian.net/browse/USH-4861
Feature Flag
Case search needs to be enabled
Safety Assurance
Safety story
Automated test coverage
Added new unit test
QA Plan
Update Potential Duplicate Clients case list in staging and perform search.
Rollback instructions
Labels & Review