diff --git a/cl/lib/elasticsearch_utils.py b/cl/lib/elasticsearch_utils.py index de19b030b5..5d6bb4eb19 100644 --- a/cl/lib/elasticsearch_utils.py +++ b/cl/lib/elasticsearch_utils.py @@ -486,6 +486,7 @@ def build_text_filter(field: str, value: str) -> List: "query": value, "fields": [field], "default_operator": "AND", + "quote_field_suffix": ".exact", } } if "caseName" in field and '"' not in value: diff --git a/cl/search/tests/tests_es_recap.py b/cl/search/tests/tests_es_recap.py index f37c0ade9b..5351e6c144 100644 --- a/cl/search/tests/tests_es_recap.py +++ b/cl/search/tests/tests_es_recap.py @@ -864,6 +864,45 @@ def test_filter_docket_with_no_documents(self) -> None: docket.delete() docket_2.delete() + def test_cause_filter(self) -> None: + """Confirm cause filter works properly""" + # Confirm parties extracted from case_name are available in filters. + with self.captureOnCommitCallbacks(execute=True): + d = DocketFactory( + court=self.court, + docket_number="23-cv-12335", + case_name="Lockhart v. Gainwell Technologies LLC", + cause="31:3730 Qui Tam False Claims Act", + source=Docket.RECAP, + ) + d_2 = DocketFactory( + court=self.court, + docket_number="22-cv-00526", + case_name="Schermerhorn v. Quality Enterprises USA, Inc.", + cause="31:3730 Qui Tam False Claims Act", + source=Docket.RECAP, + ) + + cause_str = "31:3730 Qui Tam False Claims Act" + params = { + "type": SEARCH_TYPES.RECAP, + # Do it in main query box + "q": f'cause:"{cause_str}"', + } + async_to_sync(self._test_article_count)( + params, 2, "faceted_cause_query_string" + ) + params = { + "type": SEARCH_TYPES.RECAP, + # Do it in the cause field as a phrase + "cause": f'"{cause_str}"', + } + async_to_sync(self._test_article_count)(params, 2, "cause_filter") + + with self.captureOnCommitCallbacks(execute=True): + d.delete() + d_2.delete() + def test_party_name_filter(self) -> None: """Confirm party_name filter works properly"""