Hmm, I personally use acts_as_revisable--which I love.  I haven't yet
approached the issue of indexing prior revisions (mostly, they're for
account auditing).

I'm heading home soon, so I don't have time to offer tips.  But you
might want to look at:

http://github.com/freelancing-god/thinking-sphinx/blob/8cb0eeccfee6fe803ed418da5e1a965d4fe16f60/lib/thinking_sphinx/attribute.rb

And play with the :source and with the "has" attributes.

scott

On May 21, 3:38 pm, Matt Todd <[email protected]> wrote:
> I'm tasked with indexing a model that has associations (specifically,
> this model acts_as_versioned so we have model_versions table that
> we're indexing). This is really simple and works like a charm, but now
> I need to be able to only index those versions that have a specific
> column set to a specific value (the versions acts_as_state_machine so
> we only want to index those that are marked as accepted).
>
> This means, our model should only be indexed when it is accepted.
>
> Now, I can easily handle this after the search returns normally, but
> I'd rather not. It could be done easily by modifying the SQL generated
> for the configuration file, but I can't determine how to modify the ON
> condition for joins. Is this possible or easily patchable?
>
> For instance, i would want something like:
>
> SELECT
>   models.id * 1 + 0 AS id ,
>   CAST(models.name AS CHAR) AS name,
> FROM models
>   LEFT OUTER JOIN models
>     ON model_versions.id = models.id AND model_versions.state =
> 'accepted'
> WHERE ...;
>
> Currently, my define_index block looks like this:
>
>   define_index do
>     indexes versions.names, :as => :version_names
>   end
>
> But I'd like to be able to do something like:
>
>   indexes versions.names, :as => :version_names, :if =>
> ["model_versions.state = ?", "accepted"]
>
> :conditions could be used instead, since this should be rendered as a
> condition statement.
>
> Obviously I've simplified things a bit, but all the essential
> information should be here.
>
> ALTERNATIVELY, perhaps there's a way to use attributes and filters on
> the search to create the same results? From my understanding, though,
> since all of the field values are combined, there wouldn't be a way to
> prevent select portions of the history.
>
> To be specific, the goal is to be able to search for the models and
> only return the models that have been accepted. The problem comes in
> that the models include pending and rejected versions (they are kept
> in the history) and would thus get indexed.
>
> What sucks is that the model is always the most recent edit, even if
> the most recent edit isn't the accepted version.
>
> One last alternative that I've just thought of would be to have a view
> of accepted_model_versions that I would then make a model with and
> define that as an index... or an attribute to filter on... hmm.
>
> Thanks for your input, if any ^_^
>
> Matt
>
> --
> Matt Todd
> Highgroove Studioswww.highgroove.com
> cell: 404-314-2612
> blog: maraby.org
>
> Scout - Web Monitoring and Reporting Softwarewww.scoutapp.com
--~--~---------~--~----~------------~-------~--~----~
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