Open akmiller01 opened 1 year ago
⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
I also found the following external resources that might be helpful:
https://github.com/devinit/DIwebsite-redesign/blob/develop/di_website/publications/models.py:
The page does not contain any content or code snippets relevant to the problem.
https://github.com/devinit/DIwebsite-redesign/blob/develop/di_website/publications/mixins.py:
The page does not contain any content or code snippets relevant to the problem.
From looking through the relevant snippets, I decided to make the following modifications:
File Path | Proposed Changes |
---|---|
di_website/publications/mixins.py |
In the PublicationPageSearchMixin class, update the index.SearchField to use an analyzer that tokenizes the text into individual terms. This can be done by passing an es_extra dict to the index.SearchField with the analyzer key set to the name of the new analyzer. |
I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:
Fix search to only match whole words
sweep/fix-search-whole-words
Description
This PR addresses the issue of the search functionality in the
PublicationPageSearchMixin
class indi_website/publications/mixins.py
matching partial words. The current implementation is using the default analyzer, which results in undesired matches. To fix this, the code has been modified to use a new analyzer that tokenizes the text into individual terms, each term corresponding to a word. This ensures that the search only returns results that match the whole words.Summary of Changes
- Updated the
index.SearchField
in thePublicationPageSearchMixin
class indi_website/publications/mixins.py
to use a new analyzer.- Added an
es_extra
dict to theindex.SearchField
with theanalyzer
key set to the name of the new analyzer.- The new analyzer tokenizes the text into individual terms, each term corresponding to a word, ensuring that the search only matches whole words.
Please review and merge this PR. Thank you!
I have finished coding the issue. I am now reviewing it for completeness.
Success! 🚀
To recreate the pull request, leave a comment prefixed with "sweep:" or edit the issue. Join Our Discord
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Modify di_website/publications/mixins.py or di_website/publications/models.py so stories.search(search_filter) only matches whole words. ElasticSearch is interpreting this line https://github.com/devinit/DIwebsite-redesign/blob/develop/di_website/publications/mixins.py such that a
search_filter
variable here https://github.com/devinit/DIwebsite-redesign/blob/develop/di_website/publications/models.py is returning matches for "disbursement" when thesearch_filter
is equal to "disability." The code should be modified such that asearch_filter
equal to "disability" only returns results for closely related words like "disabilities."The search is using ElasticSearch, so it's possible the solution may involve passing
es_extra
dict to theindex.SearchField
to change an argument like theanalyzer.