diff --git a/backend/apps/api/rest/v0/structured_search.py b/backend/apps/api/rest/v0/structured_search.py index 5e9f3a87dd..3d39ff2f4c 100644 --- a/backend/apps/api/rest/v0/structured_search.py +++ b/backend/apps/api/rest/v0/structured_search.py @@ -59,7 +59,7 @@ def apply_structured_search( } try: - parser = QueryParser(field_schema=parser_schema, strict=False) + parser = QueryParser(case_sensitive=True, field_schema=parser_schema, strict=False) conditions = parser.parse(query) except QueryParserError: # Fail safely diff --git a/backend/tests/apps/common/search/query_parser_test.py b/backend/tests/apps/common/search/query_parser_test.py index 168ad8304f..1ad2ea400c 100644 --- a/backend/tests/apps/common/search/query_parser_test.py +++ b/backend/tests/apps/common/search/query_parser_test.py @@ -208,3 +208,16 @@ def test_overflow_numerical_value(self): self.strict_parser.parse(f"stars:{overflow_number}") assert e.value.error_type == "NUMBER_VALUE_ERROR" + + def test_quoted_multi_word_values(self): + query = 'project:"OWASP Nest" author:"John Doe"' + results = self.parser.parse(query) + + assert len(results) == 2 + assert results[0]["value"] == '"owasp nest"' + assert results[1]["value"] == '"john doe"' + + def test_case_sensitivity_toggle(self): + query = "Author:OWASP" + cs_result = self.case_sensitive_parser.parse(query) + assert cs_result[0]["value"] == "OWASP"