Hi Peter

Are you wanting those two columns as fields or attributes? It sounds like the 
former, though you've got it set up as the latter. Perhaps this index 
definition is more appropriate?:

  define_index do
    indexes body
    indexes topic.title, :as => :topic_title
    indexes topic.forrum(:name), :as => :forum_name
    has user_id, created_at, updated_at
  end

In case you're not familiar with the difference between fields and attributes, 
the docs cover this pretty well (I think - but if I'm wrong, please tell me! :)
http://freelancing-god.github.com/ts/en/sphinx_basics.html

Cheers

-- 
Pat

On 18/12/2009, at 2:30 PM, peter wrote:

> Simple problem: I'm using the Savage-Beast forums plugin. It's great.
> I'm trying to replace its simple SQL search function with the powerful
> Sphinx/TS. Straightforward model relationship you'd expect for a
> forum:
> 
> Form has_many Topic(s) which has_many Post(s). I'm indexing only the
> Post model for now:
> 
> class Post
>  define_index do
>       indexes body
>       has user_id, created_at, updated_at
>       has topic(:title), :as => :topic_title
>       has topic.forum(:name), :as => :forum_name
>  end
> end
> 
> Obviously, topic_title and forum_name would be the dynamic attributes
> in this setup.
> 
> Running Post.search, I was hoping that each Post result would include
> these two dynamic attributes. But they don't. And I couldn't find any
> options to run with Post.search that would slurp in these attributes.
> (Savage-Beast's code wants them.)
> 
> Oddly enough, if I run the sql_query that appears in the sphinx config
> file, that search does nicely include the dynamic attributes. That
> query is clearly constructed from the "define_index" code above.
> Evidently, Post.search doesn't use that sql_query from config.
> 
> Sorry for the long post. My simple question is the following: Is there
> an elegant way to have Post.search return Post objects that contain
> the two dynamic attributes (topic_title and forum_name) defined in the
> "define_index" code?
> 
> Thanks
> 
> Peter
> 
> --
> 
> 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