Sorting Search Results Based on Weights
TLDR Pantelis wanted to sort search results by weight. Kishore Nallan suggested using "prioritize_exact_match: false" and "text_match_type: 'max_weight'" to achieve the desired result.
1
Jun 26, 2023 (3 months ago)
Pantelis
12:33 PMKishore Nallan
12:35 PMPantelis
12:45 PMDocuments: {title: 'Eat Croissant in Nice', food: ['Socca', 'Ratatouille'}
{title: 'Stroll through Montmartre's cobblestone streets', food: ['Baguette', Croissant]
query_by=title,food
query_by_weights=2,1
the second one comes first when i search for 'Croissant'
Pantelis
12:51 PMKishore Nallan
12:58 PMprioritize_exact_match: false
The exact match with the word
croissant
on the food
field is giving it a higher text match score. Weight is used to influence the ranking when match score is the same.Pantelis
12:59 PMKishore Nallan
12:59 PMtext_match_type
parameter which can help with the behavior you want.Here's what the docs say:
In a multi-field matching context, this parameter determines how the representative text match score of a record is calculated.
Possible values: `max_score` (default) or `max_weight`.
In the default `max_score` mode, the best text match score across all fields are used as the representative score of this record. Field weights are used as tie breakers when 2 records share the same text match score.
In the `max_weight` mode, the text match score of the highest weighted field is used as the representative text relevancy score of the record.
Kishore Nallan
01:00 PMtext_match_type: 'max_weight'
Pantelis
01:00 PMPantelis
01:04 PMPantelis
01:05 PMPantelis
01:06 PMKishore Nallan
01:07 PMPantelis
01:07 PM1
Typesense
Indexed 2786 threads (79% resolved)
Similar Threads
Solving Conflicts in Searching and Ordering Data with Typesense
SamHendley faced an issue with search result order in Typesense. Kishore Nallan explained two behaviors that affected the ranking and pledged to change these, while also considering an additional suggestion from SamHendley. These changes were implemented in version `0.24.0.rcn39`.
Query Weighting Issue with 'Prioritize_Exact_Match'
John is facing issues with search results prioritizing lower query weights. Kishore Nallan explained it as a limitation in text match scoring, but agreed on the need for better scoring configuration.
Understanding and Adjusting Query Parameter Weights
John needed help understanding default weights, manipulating weights, and sorting by weight in query parameters. Jason educated on default weights, sorting mechanism, and also suggested using buckets for sorting based on custom fields.
Query on "weighted_score" & Issue with Synonym Highlighting
Stefan asked about "weighted_score" field and reported a possible synonym highlighting issue. Kishore Nallan clarified the use of "weighted_score". The possible synonym issue is still being investigated.
Enhancing Search Term Matching with Query Weight Parameter
John questions if there's a solution to control term matching in search fields despite `query_weight`. Jason suggests an approach whereas Kishore Nallan cites earlier dissatisfaction with similar method but is open to think over alternatives. John further suggests a potential solution but resolution is still pending.