haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Weighted search

Open jaimeiniesta opened this issue 1 year ago • 2 comments

Hi, is there a way to define weights so that the most relevant fields give a higher score?

For example, if I have blog posts with title and body, a match on the title should be more relevant than one in the body.

jaimeiniesta avatar May 30 '23 15:05 jaimeiniesta

Alternatively, we could also specify the fields to use in the search. This way, we can search only on title, and if no results, then search on body.

jaimeiniesta avatar May 30 '23 15:05 jaimeiniesta

Hey @jaimeiniesta!

Yeah, I want to add weighted search for one of my projects that use Haystack, so that should be coming soon.

Yeah, it should be possible to perform that search by building your own query and passing it to Query.run/2. I need to expand the documentation on how to do this, so I'll try doing this as an example.

philipbrown avatar May 31 '23 07:05 philipbrown