2

Does Redisearch have any way to boost when a phrase in the query matches, even when it's not an exact phrase query, e.g. if the search is sushi bar, the sushi bar review should outscore sushi is best, bar none, while both still match. I'm wondering if such a boost is default behaviour or if not, is there some way to set it up in the query?

And if so, would it require NOOFFSETS off (since I assume it would rely on offsets data)?

Similar question for ElasticSearch. Seems like one answer there is should instead of must, but I don't think that's a thing in Redisearch. Im also wondering if Redisearch assemblies could handle it, but not sure the syntax is there to boost in that way.

mahemoff
  • 44,526
  • 36
  • 160
  • 222
  • You'd need to make it be an exact phrase match, but also use the distance (i.e. "slop") to allow for some more words in between the terms. Let me know if this works and I'll make it a proper answer – Mark Nunberg Jul 25 '19 at 11:14
  • Thanks. Not really what I'm looking for though, as I'd want it to match the terms in any order (and any distance), ie just a regular search, except that exact match is boosted. – mahemoff Jul 25 '19 at 12:59
  • 1
    Seems like you could do something like `(sushi bar) => {$weight: 10} ~("sushi bar") => {$weight: 20}` – Mark Nunberg Jul 26 '19 at 17:15
  • Thanks, some quick testing indicates this works well. You can add it as an answer if you like. – mahemoff Jul 31 '19 at 19:11

1 Answers1

1

You could do something like (sushi bar) => {$weight: 10} ~("sushi bar") => {$weight: 20}. The explanation is that sushi bar as an intersection (AND) query; whereas the exact phrase "sushi bar" is an optional (~) booster query.

Mark Nunberg
  • 3,551
  • 15
  • 18