#community-help

Tuning Query Results Order with Query_by_Weights

TLDR Nathan is trying to tune the order of results using query_by_weights, but experiences a smaller impact than expected. Jason suggests trying max_weight and sharing a snippet to further investigate.

Powered by Struct AI

1

Jun 13, 2023 (6 months ago)
Nathan
Photo of md5-aa846ac80f1164f0d27b340467fd28e2
Nathan
09:16 PM
I'm playing around with query_by_weights to try and slightly tune the order of my results when sorted by _text_match:desc . I'm finding that query_by_weights has a much smaller impact than I expected.

My search has 10 query_by fields and returns 2 results.
Document X matches the query only on the 10th field. Document Y matches on the 7th, 8th and 9th fields.
num_typos=0
Fields 7-10 are nested fields, in case that matters.


text_match_info.score
X = 578730123365711921
Y = 578730123365187659

with query_by_weights=1,1,1,1,1,1,1,1,1,127
X = 578730123365711993 (+72)
Y = 578730123365187699 (+40)

I expected bigger changes in score, given that I'm weighting field10 127x any other field. What am I not understanding correctly here?
Jun 14, 2023 (6 months ago)
Nathan
Photo of md5-aa846ac80f1164f0d27b340467fd28e2
Nathan
02:00 PM
Jason following up here
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:55 PM
Nathan I suspect itโ€™s related to the text_match_type. Could you try setting it to max_weight?
03:56
Jason
03:56 PM
In any case, it would be helpful to use actual textโ€ฆ Could you clone this snippet, update it with your data (just a few records) and share it here?

1

Nathan
Photo of md5-aa846ac80f1164f0d27b340467fd28e2
Nathan
03:58 PM
From what I read in the docs, if I use max_weight, the result is purely based on the highest weighted field. I was hoping to still search across all fields -- something like "Field 1 is more important than field 2 OR 3, but if both field 2 AND 3 match the query, that trumps field 1"

Regardless, I'll work on that snippet later today
04:14
Nathan
04:14 PM
I unfortunately cannot share my schema publicly
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:33 PM
Are you able to DM me the snippet?
Nathan
Photo of md5-aa846ac80f1164f0d27b340467fd28e2
Nathan
04:48 PM
Yes, I can do that when I have time ๐Ÿ‘

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Phrase Search Relevancy and Weights Fix

Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.

6

111
8mo
Solved

Issues With `text_match` Scoring for Search Queries in Typesense

Colin encountered issues with the `text_match` scoring on Typesense v0.23.1. Jason and Kishore Nallan identified a potential issue with numeric overflow in the text match score and applied an unverified patch. The final resolution is unclear.

8

33
17mo

Resolving Typesense Result Issue in Document Collection Queries

Mike was encountering errors when searching for specific query in their Typesense document collection. Jason suggested it may be due to the `drop_tokens_threshold` setting. There was a misunderstanding but after further explanation from Jason, Mike understood and decided to continue the conversation via email.

1

19
21mo

Document Weighting and Sorting Discussion

SamHendley asked how to weight a document based on age and offered a sorting method. Jason clarified the method and suggested an RC for use. SamHendley tested and confirmed the solution. User Kishore Nallan assisted when an error occurred with a new feature.

1

30
11mo

Troubleshooting Issues with DocSearch Hits and Scraper Configuration

Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.

7

131
8mo
Solved