Help: Different results for global search vs model search

8 views
Skip to first unread message

rpheath

unread,
Dec 28, 2009, 11:53:10 AM12/28/09
to Thinking Sphinx
I'm using ThinkingSphinx.search (global search) to search across
multiple models. For simplicity, I'll refer to two models: Article and
Comment.

I'm wrapping the ThinkingSphinx search into a Search model that groups
the results into an ordered hash so I can then pull out the results
for whichever model I'm looking for (useful for a multi-result search
page). So it's something like this:

<pre>
class Search
def self.grouped(keywords)
ThinkingSphinx.search(keywords).group_by { |kind|
kind.class.to_s.underscore }
end
end
</pre>

So on the multi-result page I'm only showing the top 5 of each model,
with a link to "see all" that shows the full results page. The problem
is, the results are different for global search vs. model search. For
example:

<pre>
>> Article.search('morgantown').size
>> # => 125
>> Search.grouped('morgantown')["article"].size
>> # => 19
</pre>

My only thought is I'm also indexing the associated tags for the
Article model, and maybe the global search doesn't search across the
tags (associated indexes) as well?

Any help would be greatly appreciated!

Pat Allan

unread,
Dec 28, 2009, 10:01:39 PM12/28/09
to thinkin...@googlegroups.com
I'm assuming you're passing in a custom :per_page option - because otherwise you wouldn't get 125 results in your first example. How high is this value? It's possible there's enough other matches for other classes, that only 19 article results get through to your global search.

All searches look at all fields, unless you're using :conditions (or manually constructing an extended query string), so the associated tags won't be the problem.

--
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.
>
>

Reply all
Reply to author
Forward
0 new messages