Revert "Features: 1) Add SearchAsYouTypeField to name field in ProductDocument for improved search capabilities; 2) Introduce product_type and sales_rank fields to ProductDocument with preparation methods; 3) Add total_orders property to model for calculating product order count;"

This reverts commit 432e4bf1
This commit is contained in:
Egor Pavlovich Gorbunov 2025-06-20 03:28:27 +03:00
parent e541dfd624
commit efd927f4d1
2 changed files with 2 additions and 12 deletions

View file

@ -183,7 +183,6 @@ COMMON_ANALYSIS = {
},
"query_lc": {"tokenizer": "standard", "filter": ["lowercase", "asciifolding"]},
},
"normalizer": {"lc": {"type": "custom", "filter": ["lowercase", "asciifolding"]}},
}

View file

@ -1,4 +1,4 @@
from django_elasticsearch_dsl import Document, SearchAsYouTypeField, fields
from django_elasticsearch_dsl import Document, fields
from django_elasticsearch_dsl.registries import registry
from core.elasticsearch import COMMON_ANALYSIS, ActiveOnlyMixin, _add_multilang_fields
@ -10,8 +10,7 @@ class _BaseDoc(ActiveOnlyMixin, Document):
attr="name",
analyzer="standard",
fields={
"raw": fields.KeywordField(ignore_above=256, normalizer="lc"),
"sat": SearchAsYouTypeField(max_shingle_size=4),
"raw": fields.KeywordField(ignore_above=256),
"ngram": fields.TextField(
analyzer="name_ngram", search_analyzer="query_lc"
),
@ -54,14 +53,6 @@ class _BaseDoc(ActiveOnlyMixin, Document):
class ProductDocument(_BaseDoc):
rating = fields.FloatField(attr="rating")
product_type = fields.KeywordField()
sales_rank = fields.IntegerField()
def prepare_product_type(self, obj):
return obj.category.slug.split("-")[0] if obj.category else "other"
def prepare_sales_rank(self, obj):
return obj.total_orders or 0
class Index(_BaseDoc.Index):
name = "products"