fix: search fix for magazines and other docs

This commit is contained in:
Krispire Admin
2026-05-10 23:22:37 +05:30
parent e3f14ef8ba
commit 00b862f77e
2 changed files with 20 additions and 3 deletions
+12
View File
@@ -181,6 +181,8 @@ func (h *SearchHandler) multiSearch(ctx context.Context, collections []string, q
}
exhaustive := true
prioritizeExact := true
prioritizeTokenPos := true
searches := make([]api.MultiSearchCollectionParameters, 0, len(collections))
for _, col := range collections {
queryBy := collectionQueryByFields[col]
@@ -196,6 +198,10 @@ func (h *SearchHandler) multiSearch(ctx context.Context, collections []string, q
Prefix: stringPtr("true"),
NumTypos: stringPtr("2"),
ExhaustiveSearch: &exhaustive,
// Boost docs whose tokens are exact matches and appear early in the field
// so "karma" outranks "karmic" and frequent matches outrank single ones.
PrioritizeExactMatch: &prioritizeExact,
PrioritizeTokenPosition: &prioritizeTokenPos,
}
if weights != "" {
params.QueryByWeights = stringPtr(weights)
@@ -254,6 +260,8 @@ func (h *SearchHandler) singleSearch(ctx context.Context, collection, query stri
}
exhaustive := true
prioritizeExact := true
prioritizeTokenPos := true
params := &api.SearchCollectionParams{
Q: stringPtr(query),
QueryBy: stringPtr(queryBy),
@@ -262,6 +270,10 @@ func (h *SearchHandler) singleSearch(ctx context.Context, collection, query stri
Prefix: stringPtr("true"),
NumTypos: stringPtr("2"),
ExhaustiveSearch: &exhaustive,
// Boost docs whose tokens are exact matches and appear early in the field
// so "karma" outranks "karmic" and frequent matches outrank single ones.
PrioritizeExactMatch: &prioritizeExact,
PrioritizeTokenPosition: &prioritizeTokenPos,
}
if weights := collectionQueryByWeights[collection]; weights != "" {
params.QueryByWeights = stringPtr(weights)