Feature/6076 add proximity search #6087
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary (required)
This PR adds a proximity search to our legal search endpoint for AO, ADR, MUR, and AFs. The four new filters are
q_proximity
,max_gaps
,proximity_filter
, andproximity_filter_term
.Note: I removed highlighting for proximity search because it does not work with intervals queries.
Please see the previous research ticket for an in depth breakdown.
Required reviewers 2 - 3 developers
Impacted areas of the application
General components of the application that this PR will affect:
How to test
./elasticsearch
pytest
python cli.py create_index case_index
python cli.py create_index ao_index
python cli.py load_current_murs
python cli.py load_admin_fines
python cli.py load_advisory_opinions
python cli.py load_adrs
flask run
Test URLs reference the following documents: MUR 8285, ADR 1175, AF 4774, AO 2024-15
MUR:
One phrase:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Dowell%20daunting&max_gaps=2
Multiple phrases:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=daunting%20task&q_proximity=actively%20campaigning&q_proximity=represent%20Illinois&max_gaps=12
With filter:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Dowell%20daunting&max_gaps=2&proximity_filter=after&proximity_filter_term=remediation
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Dowell%20daunting&max_gaps=2&proximity_filter=before&proximity_filter_term=remediation
ADR:
One phrase:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=RAD%20Wisconsin&max_gaps=5
Multiple phrases:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Polls%20Wisconsin&q_proximity=twenty-two&max_gaps=13
With filter:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Polls%20Wisconsin&q_proximity=twenty-two&max_gaps=13&proximity_filter=after&proximity_filter_term=RAD
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Polls%20Wisconsin&q_proximity=twenty-two&max_gaps=13&proximity_filter=before&proximity_filter_term=RAD
AF:
One phrase:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Datwyler%20McGuire&max_gaps=4
Multiple phrases:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=%20Thomas%20Datwyler&q_proximity=reason%20to%20believe&max_gaps=5
With filter:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Datwyler%20McGuire&max_gaps=4&proximity_filter=after&proximity_filter_term=%20Pre-Primary%20Report
http://127.0.0.1:5000/v1/legal/search/?q_proximity=Datwyler%20McGuire&max_gaps=4&proximity_filter=before&proximity_filter_term=%20Pre-Primary%20Report
AO:
One phrase:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=LAMA%20illegitimate%20&max_gaps=6
Multiple phrases:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=misappropriation%20&q_proximity=membership%20dues&max_gaps=2
With filter:
http://127.0.0.1:5000/v1/legal/search/?q_proximity=LAMA%20illegitimate%20&max_gaps=6&proximity_filter=before&proximity_filter_term=misappropriation
http://127.0.0.1:5000/v1/legal/search/?q_proximity=LAMA%20illegitimate%20&max_gaps=6&proximity_filter=after&proximity_filter_term=misappropriation