Hi all
I'm trying to implement a searching with grouped results as follows:
It is a one-to-many relation between Topics and Posts, where each
Topic has the title and many Posts, which each one has its own text.
I'm trying to make the search by Posts so in the results page I can
point to the Topic but placing the navigator to the Post where the
match appears. Everything works fine until here:
in the Post model:
belongs_to :topic
define_index do
# fields
indexes topic.title, :as => :related_topic_title
indexes text
indexes created_at, :sorteable => true
# attributes
has created_at
has topic(:id), :as => :related_topic_id # field is topic_id
in Posts
end
in the controller, within the search action:
@posts = Post.search params[:q]
Ok, now the problem:
If in a Topic there's more than one Post where there is a match, I
recieve (obviously) all the posts. But as I want to show the results
by Topic, I need to group all posts by Topic. I tried a lot of
combinations:
@posts = Post.search params[:q], :group_by => :related_topic_id
[ERROR: undefined method 'bytesize' for symbol]
@posts = Post.search params[:q], :group_funcion => :related_topic_id
[ERROR: can't convert nil to Integer]
@posts = Post.search params[:q], :group_by => 'topic_id' [FAILS: no
matches!!]
@posts = Post.search params[:q], :group_funcion
=> :related_topic_id, :group_clause => "created_at DESC" [FAILS: no
grouping is done]
So, as documentation is a little poor in grouping, can anyone help me
on this? How can I group all Posts in a Topic? Ideally, pointing to
the first Post of that matches in a Topic is enough...
Keep in mind I'm a newbe on Sphinx
Thank you for your time.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---