elixir-haystack / haystack

Simple, extendable full-text search engine written in Elixir
MIT License
195 stars 3 forks source link

Weighted search #4

Open jaimeiniesta opened 1 year ago

jaimeiniesta commented 1 year ago

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 commented 1 year ago

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.

philipbrown commented 1 year ago

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.