I'm trying to search across multiple models in my Rails 3.2 app
(thinking-sphinx gem version 2.0.12), which has models like:
class Story < ActiveRecord::Base
define_index do
indexes title
set_property :field_weights => {
:title => 100,
}
end
end
and
class Anthology < ActiveRecord::Base
define_index do
indexes head
set_property :field_weights => {
:head => 100,
}
end
end
When I search using Story.search or Anthology.search, I get results with
weights of 100+, e.g.:
irb> Story.search("dogs").results[:matches].map { |m| m[:weight] }
[111, 111, 111, 111, 101, 101, 101, 101, 101, 101, 101, 101, 100, 100, 100,
100, 100, 100, 100, 100]
irb> Anthology.search("dogs").results[:matches].map { |m| m[:weight] }
[101, 101, 101, 1, 1, 1, 1, 1]
However, if I use ThinkingSphinx.search with the same query string, the
weights are much lower and the resulting order is is not what I would
expect given the weights from the Story and Anthology searches, e.g.:
irb> ThinkingSphinx.search("dogs").results[:matches].map { |m| m[:weight] }
[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]
It appears as though the field_weight definitions are ignored when I search
multiple models. Is there any way to use fields weights when searching this
way?
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.