For our search we have a rather obscure situation.

A "Resource" can have many "ResourceRevisions" and these are number
sequentially, so that the a Resource ID of 1 and a ResourceRevision of
1 is the first entry of a Resource.

What this means for searching is that in our ResourceRevision model
have:
set_sphinx_primary_key :resource_id

And our define is:

define_index do
    indexes title
    indexes description
    indexes short_description
    indexes resource(:id), :as => :resource, :sortable => true

    where "NOT EXISTS (SELECT resource_id, id FROM resource_revisions
AS rrs WHERE ((`resource_revisions`.`resource_id`=`rrs`.`resource_id`)
AND (`rrs`.`id` > `resource_revisions`.`id`)))"

    set_property :enable_star => true
    set_property :min_prefix_len => 3

    has resource_id, created_at, updated_at
end

The aim of our where is to select the latest entry in the resource
ideas and only search that; however either I wrote this incorrectly,
or are not using it correctly in searches, as it will bring up search
results from earlier revisions.

An example is:
titles = ResourceRevision.search :conditions => { :title =>
params[:query] }, :star => true

This will return older resource revisions, and because we use the
excerpts we need it to only search the latests, as otherwise that
method explodes if we just tell it to use the latest version of
whatever resource revision it gets.

So are we approaching this from completely the wrong route, or have we
just missed a step or should it work?

Any help will be gratefully appreciated

plcs

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