3

I have a index set up so I can facet on category ids, as following:

define_index
  ...

  has categorizings.category_id, :type => :multi, :facet => true
end

When I do a query like Listing.facets, I get the correct results in a hash, with each category_id pointing at its count. :)

The only problem is Thinking Sphinx runs a database query and loads many (but not all) of these objects! Since this attribute is just MVA integers; I wouldn't think they would require any translation.

What's going on here? Is there any way for performance's sake I can stop Thinking Sphinx from instanciating all these ActiveRecord objects?(there can be hundreds!) Or is there a better way to achieve this with Sphinx and Thinking Sphinx?

Thanks!

Ben Crouse
  • 8,290
  • 5
  • 35
  • 50
  • freelancing-god.github.com/ts/en/searching.html#ids mail-archive.com/thinking-sphinx@googlegroups.com/msg06035.html Maybe this links can help you. – Claudio Acciaresi Feb 18 '11 at 12:53

1 Answers1

0

It looks like you can use search_for_ids() instead of the main search() entrypoint with thinking sphinx to return just the primary keys for your results and not load up all the objects.

http://freelancing-god.github.com/ts/en/searching.html#ids

Winfield
  • 18,985
  • 3
  • 52
  • 65