Hi Johann

Answers in context below…

On 13/11/2012, at 7:50 PM, Johann Tagle wrote:

> Hi.  First of all thank you for creating and sharing this project.  I have 
> two questions:
> 
> 1.  I noticed in the generated configuration file under "sql_query" the id 
> for the index is computed as CAST(2 AS SIGNED) + 1.  Any reason for this vs 
> just using the id as is?  Is there any way to have TS to just do the latter?  
> The reason for asking is I also use the MySQL SphinxSE plugin for 
> data-mining, etc and it looks ugly to always have to include a 
> "((sphinx_search_table.id - 1) / 2)" when joining the search results table 
> with the table of the model and/or other tables.

Thinking Sphinx can't use the primary key values directly, because Sphinx 
requires unique document ids across *all* indices, not just each one. Hence, 
you'd end up with collisions.

However, if you look at the generated configuration file, you'll also spot an 
attribute for the primary key value, which may make things easier for you.

> 2.  We use acts_as_taggable_on and I've seen many examples on how to index 
> tags in relation to the model.  However, we have a requirement where we want 
> to index the Tag/Tagging models themselves so that we can use that index for 
> autocomplete.  I know how to use TS for autocomplete, but I'm quite at a loss 
> how to index the Tag/Tagging models on their own.  Can this be done?

Hmm… I'm not entirely sure of the best way to manage this, but you'll probably 
need to add something like the following to a file that'll be automatically 
loaded (to ensure it's part of your app):

  Tag.define_index do
    # …
  end

  Tagging.define_index do
    # …
  end

Class methods are class methods, after all.

Cheers

-- 
Pat


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

Reply via email to