Hi Tony

You're definitely wading into undocumented (and untried) waters - I've
not done this before, nor have I heard of anyone trying to do this
before.

Still, it shouldn't be too difficult (in theory). The code you want to
keep an eye on is ThinkingSphinx::Index::Builder... but here's an
example, adding an attribute to a given source:

  source = Order.sphinx_indexes.first.sources.first
  columns = FauxColumn.coerce(:created_at)
  options = {:type => :datetime} # not needed in this case - TS will
figure it out
  ThinkingSphinx::Attribute.new(source, columns, options)

An index can have many sources, but starts with just one, so you should
be able to access existing sources easily enough. The columns can be
symbols referring to columns, and the options are a hash of options you
may pass through to a 'has' call normally. Also: the attribute will
automatically add itself to the source.

Hope this helps!

--
Pat

On 9/1/2010, "BigRefT" <[email protected]> wrote:

>I have searched and searched but have yet to find any info on if this
>is possible. I have an Order model that calls define_index in the main
>app. I am creating a plug-in that extends the Order model and I want
>to insert a new attribute into the index for Order. Is this possible?
>
>I have read through post after post with nothing even close, and I
>have tried to go into the TS code base and see if I can do it
>manually.
>
>The closest I got was this:
>
>Order.sphinx_index.first.attributes << ...
>
>Where ... would be the missing piece. I know it needs to be an
>Attribute, but I don't where to start.
>
>Any help would be appreciated.
>
>Thanks
>Tony
>
>--
>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.

Reply via email to