From 9d4a672d67dd6d03664867e746751a05c9fdde48 Mon Sep 17 00:00:00 2001 From: Kuroshini Date: Wed, 16 Oct 2019 14:11:07 +0300 Subject: [PATCH] Multilingual textfield products analyzers --- apps/search_indexes/documents/product.py | 4 +++- apps/search_indexes/views.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/search_indexes/documents/product.py b/apps/search_indexes/documents/product.py index 9e57c607..cb0131cb 100644 --- a/apps/search_indexes/documents/product.py +++ b/apps/search_indexes/documents/product.py @@ -95,7 +95,9 @@ class ProductDocument(Document): }, multi=True ) - name = fields.TextField(attr='display_name') + name = fields.TextField(attr='display_name', analyzer='english') + name_ru = fields.TextField(attr='display_name', analyzer='russian') + name_fr = fields.TextField(attr='display_name', analyzer='french') class Django: model = models.Product diff --git a/apps/search_indexes/views.py b/apps/search_indexes/views.py index dcc6f895..174b1dd8 100644 --- a/apps/search_indexes/views.py +++ b/apps/search_indexes/views.py @@ -216,7 +216,11 @@ class ProductDocumentViewSet(BaseDocumentViewSet): search_fields = { 'name': {'fuzziness': 'auto:2,5', - 'boost': 4}, + 'boost': 8}, + 'name_ru': {'fuzziness': 'auto:2,5', + 'boost': 6}, + 'name_fr': {'fuzziness': 'auto:2,5', + 'boost': 7}, 'transliterated_name': {'fuzziness': 'auto:2,5', 'boost': 3}, 'description': {'fuzziness': 'auto:2,5'},