We're indexing businesses by name and category (and some other
fields). We want to ensure that something that matches *exactly* in
name or category will be boosted above something that is a partial
match or match across fields (ie, if I search for "Burger Bar" in Las
Vegas, the business by the name of "Burger Bar" should be returned
above the business "Al's Bar" that has also been categorized as
"Burgers", also above something like "Johnny's Bar and Burgers").
We're doing expression sorting, so we would need to be able to do
something like "+ @exact_match*10", where @exact_match would be 1 if
it's an exact match or 0 otherwise. That's just what I was hoping for
-- any way to achieve a similar result would be spectacular.
Thanks,
Steve
You may want to look at having a second index, with just the name in it, and then you should be able to rank that index a bit higher.
define_index 'business_name' do
indexes name
end
And then for searching:
Business.search 'burger bar', :index_weights => {'business_name_core' => 10}
Any indexes not mentioned have a default weighting of 1. The only catch with this is that 'burger bar' will match 'Burger Bar', 'Bar Burger', and 'Just Another Burger Bar'. Still, maybe that's good enough for what you need to do?
There's no special attribute for exact matches, I'm afraid, so you can't factor it in to the custom sorting algorithm. And this is all theory - I've not tried it myself, but I think it's worth a shot.
Cheers
--
Pat
> --
>
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
Wouldn't that be equivalent to giving the "name" field a higher
weight?
I think that at this point, the best way for us to get exact name
matches back first will be to use the phrase searching, and do two
searches, one for a phrase, and one regular. But I will argue against
the overhead this would cause, so I guess we're just going to punt on
this requirement. :)
Thanks for your help and thoughts on this.
-Steve
--
Pat