**Features**: 1) Add score_mode="first" to function_score query configuration for enhanced scoring;
**Fixes**: None; **Extra**: 1) Wrap product-specific attributes like `rating` and `brand_priority` in a debug-mode conditional block;
This commit is contained in:
parent
0e4d5fe59f
commit
3160ab4549
1 changed files with 12 additions and 4 deletions
|
|
@ -79,7 +79,8 @@ def process_query(query: str = "", request: Request | None = None) -> dict[str,
|
|||
},
|
||||
}
|
||||
],
|
||||
boost_mode="sum",
|
||||
boost_mode="multiply",
|
||||
score_mode="first",
|
||||
)
|
||||
|
||||
search = Search(index=["products", "categories", "brands", "posts"]).query(function_score_query).extra(size=100)
|
||||
|
|
@ -121,9 +122,16 @@ def process_query(query: str = "", request: Request | None = None) -> dict[str,
|
|||
"image": image_url,
|
||||
}
|
||||
|
||||
if idx == "products":
|
||||
hit_result["rating"] = getattr(hit, "rating", 0)
|
||||
hit_result["brand_priority"] = getattr(hit, "brand_priority", 0)
|
||||
if settings.DEBUG:
|
||||
if idx == "products":
|
||||
hit_result["rating"] = getattr(hit, "rating", 0)
|
||||
hit_result["brand_priority"] = getattr(hit, "brand_priority", 0)
|
||||
if idx == "brands":
|
||||
pass
|
||||
if idx == "categories":
|
||||
pass
|
||||
if idx == "posts":
|
||||
pass
|
||||
|
||||
results[idx].append(hit_result)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue