Hi there
If you're after search results, not a search breakdown by category, then facets
isn't the best tool for the job. You should just be able to search across all
models:
ThinkingSphinx.search @query, :star => true
As for dealing with different objects, I'd recommend writing a view helper to
determine where to send links. Of course, if all objects have a name (or
whatever you want the link text to be), and have matching controllers/resources
set up, then you could just loop through like so:
<%- @results.each do |result| -%>
<li><%= link_to result.name, result %></li>
<%- end -%>
And Rails will figure out the rest. This isn't particularly flexible though.
As for getting *all* results, there is an inherent limit for Sphinx and how it
works, but you can work around it to some extent (essentially, you can't turn
pagination off, but you can request really big pages):
http://freelancing-god.github.com/ts/en/advanced_config.html#large-result-sets
--
Pat
On 09/12/2009, at 10:51 PM, plcs wrote:
> Hi,
>
> I've been banging my head against the nearest wall trying to find the
> best way to create links from the results I get back from searching
> across all my models. Essentially I want it so that there is a single
> search controller that will search all my existing models and return
> the results of the search, with links to the page in question.
>
> So is facet's the way to go, or should I be using the normal Search?
>
> Below is how I perform the facet search, and it works fine, my trouble
> is handling the output it gives me.
>
> def search
> @query = params[:query]
> @facets = ThinkingSphinx.facets @query, :all_facets => true,
> :star => true
> respond_to do |format|
> format.html
> format.xml { render :xml => @facets }
> end
> end
>
> <div class="search">
> <% @facets.each do |facet, facet_options| %>
> <% unless facet_options.blank? %>
> <h5><%= facet %></h5>
> <ul>
> <% facet_options.each do |option, count| %>
> <li><%= link_to "#{option} (#{count})",
> :params => {facet => option, :page => 1} %></li>
> <% end %>
> </ul>
> <% end %>
> <% end %>
> </div>
>
> Basically I don't want the situation where I have to check the
> instance of the option to decide what path from routes to give it, I'd
> really prefer it if there was a general method that'll find this for
> me.
>
> Should I really be using facets here, or normal search?
>
> And as a side note, is there anyway to get ALL results from search?
> Not just the first 10?
>
> Thank you for your help.
>
> plcs
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.