Hi,
I'm working on a project trying to get this work:
A model have different kind of tags, i'm using acts-as-taggable-on
plugin
So the first approach was use the has method like this:
has region(:id), :as=>:region_ids, :facet=>true
// repeated 8 times for other kind of tags
But when running rake ts:rebuild the SQL generated use a lot of LEFT
OUTER JOINs and the query with just a few records is incredibly slow.
I read in other threads that the tags can be indexed with :source
=> :query so the next was:
has "SELECT taggable_id
#{ThinkingSphinx.unique_id_expression(Topic.sphinx_offset)} , tag_id
FROM taggings WHERE taggable_type = 'Topic' AND context = 'region'
", :source => :query, :as => :region_ids, :facet => true
In this case, the index is a lot faster, but the facets are not
working
The attributes generated on the config file are:
sql_attr_multi = uint region_ids from query; SELECT taggable_id * 4
+ 2 , tag_id FROM taggings WHERE taggable_type = 'Topic' AND context =
'region'
sql_attr_multi = uint region_ids_facet from query; SELECT
taggable_id * 4 + 2 , tag_id FROM taggings WHERE taggable_type =
'Topic' AND context = 'region'
The region_ids attr is indexed and working fine, but the
region_ids_facet doesn't work when trying to get facets:
rails_console> Topic.facets
NoMethodError: undefined method `SELECT taggable_id * 4 + 2 , tag_id
FROM taggings WHERE taggable_type = 'Topic' AND context = 'region' '
for #<Topic:0x104f3a688>
There is a way to get the region_ids work as faceted directly b/c it's
already indexed fine ?
Another option I was thinking is that the left outer joins generate a
list of tags as a field with group_concat so I was trying to cache the
tag ids on a field in the main table and use it as:
has region_ids, :multi => true, :facet => true # This is not
generating correct facets #where region_ids now is a field
But doesn't work looks like it's indexed but the search doesn't work.
The facets field is doing a CRC32 of the region_ids field not taking
the ids separated by commas.
Well that is all i'm trying, next step is trying to make work with
good performance the method that works, so if some one can guide me
through the TS code i can try to do it by myself.
Thanks.
--
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.