4

In RediSearch, how do optional query and weight work?

Right now, when I try to search a keyword and use an optional query with weight to boost result, it doesn't seem to do anything.

I have tried RediSearch 1.4.0 and 1.4.15.

I have an indexed document with different TEXT fields of variable sizes and while indexing I have given them document_score. Now I want my users to be able to search for a document by making a query but I want to boost those results that exactly match the query to be at the top.

I have seen scoring algorithms provided by redis but none of them seem to do anything with the $weight we provide to a subquery. All of them talk about field weights, document_score and query term frequencies. None of them talk about $weight in a query and how it will affect the end result.

Lets say I have 4 documents with different text fields. One of them is title field which is TEXT. The entries of title fields of each 4 documents are as follows:

"mohsin conversation with the mohsin"
"conversation the conversation - a drama about conversation, the science of conversation."
"Fareham Community Church - Sermons and conversations mohsin conversation the"
"mohsin conversation the conversation tahir"

When I generate the following query to redisearch

@title:(conversation the conversation*) (~@title:"conversation the conversation"=>{$weight: 10;})

I expect the documents with exact conversation the conversation to be at top and all other results (having slop distance > 0) after them.

But the output is totally different. i.e.

"Fareham Community Church - Sermons and conversations mohsin conversation the"
 "mohsin conversation with the mohsin"
 "conversation the conversation - a drama about conversation, the science of conversation."
 "mohsin conversation the conversation tahir"

So I want to understand the role of subqueries weight in the final result.

Akshay Anurag
  • 724
  • 1
  • 8
  • 27
Mohsin Sethi
  • 803
  • 4
  • 16

0 Answers0