Hello, I've got a field that I am indexing as a boolean, mainly
it's the episodes field in our table. The idea is that if an entry
has > 0 episodes it be listed further down the
search results. As such I've added this to the index:
has 'episode > 0', as: :episode, type: :boolean
And this to our searches results:
common_search_attributes[:field_weights] = {title: 40, director: 30, starring: 20, episode: 3}
common_search_attributes gets called for all
searches.
We figured that by adding a very smal weight to the episode
boolean field we'd see the results with episodes listed together
further down. However, after reindexing and searching with and
without the episode: 3 change the results are exactly
the same.
What are we doing wrong?
Thanks.
#1 Posted by Pat Allan Support staff on 23 Sep, 2014 04:56 PM
Hi Alex
Unfortunately, field weights only work with fields, not attributes.
There's two other ways to approach this I can think of: order by weight and then by episode:
The second approach is similar, but allows for more complexity: create your own weighting formula
http://sphinxsearch.com/docs/manual-2.1.9.html#expressions has more details on functions and such you can use.
Cheers
Pat
#2 Posted by alex on 24 Sep, 2014 09:44 AM
Thanks a lot Pat, I’ll try this.
—
Sent from my iPad, please excuse hypos.