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:
parent
e541dfd624
commit
efd927f4d1
2 changed files with 2 additions and 12 deletions
|
|
@ -183,7 +183,6 @@ COMMON_ANALYSIS = {
|
||||||
},
|
},
|
||||||
"query_lc": {"tokenizer": "standard", "filter": ["lowercase", "asciifolding"]},
|
"query_lc": {"tokenizer": "standard", "filter": ["lowercase", "asciifolding"]},
|
||||||
},
|
},
|
||||||
"normalizer": {"lc": {"type": "custom", "filter": ["lowercase", "asciifolding"]}},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 django_elasticsearch_dsl.registries import registry
|
||||||
|
|
||||||
from core.elasticsearch import COMMON_ANALYSIS, ActiveOnlyMixin, _add_multilang_fields
|
from core.elasticsearch import COMMON_ANALYSIS, ActiveOnlyMixin, _add_multilang_fields
|
||||||
|
|
@ -10,8 +10,7 @@ class _BaseDoc(ActiveOnlyMixin, Document):
|
||||||
attr="name",
|
attr="name",
|
||||||
analyzer="standard",
|
analyzer="standard",
|
||||||
fields={
|
fields={
|
||||||
"raw": fields.KeywordField(ignore_above=256, normalizer="lc"),
|
"raw": fields.KeywordField(ignore_above=256),
|
||||||
"sat": SearchAsYouTypeField(max_shingle_size=4),
|
|
||||||
"ngram": fields.TextField(
|
"ngram": fields.TextField(
|
||||||
analyzer="name_ngram", search_analyzer="query_lc"
|
analyzer="name_ngram", search_analyzer="query_lc"
|
||||||
),
|
),
|
||||||
|
|
@ -54,14 +53,6 @@ class _BaseDoc(ActiveOnlyMixin, Document):
|
||||||
|
|
||||||
class ProductDocument(_BaseDoc):
|
class ProductDocument(_BaseDoc):
|
||||||
rating = fields.FloatField(attr="rating")
|
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):
|
class Index(_BaseDoc.Index):
|
||||||
name = "products"
|
name = "products"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue