diff options
-rw-r--r-- | CHANGES.md | 5 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 9 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 6 |
3 files changed, 17 insertions, 3 deletions
diff --git a/CHANGES.md b/CHANGES.md index ac68074fc..4af5eed6a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,11 @@ title: Ishtar changelog date: 2022-12-05 --- +### Features/improvements ### + +### Bug fixes ### +- Full text search: add "simple" config in search + v4.0.31 - 2022-12-05 -------------------- diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 9a5f35d9b..36b96176a 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -2866,6 +2866,7 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): # test vector search with accents operation = models.Operation.objects.get(pk=self.operations[0].pk) operation.common_name = "Opération : Château de Fougères" + operation.operator_reference = "ROYER" operation.save() response = c.get(reverse("get-operation"), {"search_vector": "chaTEAU"}) result = json.loads(response.content.decode()) @@ -2877,6 +2878,14 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): response = c.get(reverse("get-operation"), {"search_vector": "chaTEAU - "}) result = json.loads(response.content.decode()) self.assertEqual(result["recordsTotal"], 1) + # test french search + response = c.get(reverse("get-operation"), {"search_vector": "roye"}) + result = json.loads(response.content.decode()) + self.assertEqual(result["recordsTotal"], 1) + # test simple search + response = c.get(reverse("get-operation"), {"search_vector": "royer"}) + result = json.loads(response.content.decode()) + self.assertEqual(result["recordsTotal"], 1) def test_complex_search_vector(self): c = Client() diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index b8cc24fb4..2f9cfc55a 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -826,10 +826,10 @@ def _search_manage_search_vector( dct["extras"].append( { "where": [ - model._meta.db_table - + ".search_vector @@ (to_tsquery(%s, %s)) = true" + f"{model._meta.db_table}.search_vector @@ (to_tsquery(%s, %s)) = true OR " + + f"{model._meta.db_table}.search_vector @@ (to_tsquery('simple', %s)) = true" ], - "params": [settings.ISHTAR_SEARCH_LANGUAGE, search_query], + "params": [settings.ISHTAR_SEARCH_LANGUAGE, search_query, search_query], } ) return dct, exc_dct, distinct_queries |