thanks for the response, once you told me my queries looked right I
figured the problems has to be in indexing, and with a closer look I
saw the problem was

has labels(:id), :as => label_ids
which should have been
has labels(:id), :as => :label_ids

Im glad I asked early and didn't spend a lot of time on such a stupid
bug :) it's working fine now

thanks a lot
Soheil Danesh


On Aug 3, 3:46 am, Pat Allan <[email protected]> wrote:
> Have you reindexed your data and restarted Sphinx since adding the label_ids 
> attribute? (This will make sure Sphinx is aware of the current index schema.) 
> Because your search queries look fine.
>
> What happens if you search without the text, just with the filter on 
> label_ids?
>
> --
> Pat
>
> On 03/08/2011, at 12:32 AM, soheildb wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > So here's my problem:
> > I have a Post model
>
> > Post :has_many :post_labels
> > Post :has_many :labels, :through => :post_labels
>
> > I want to be able to search through posts that have a certain label.
>
> > what I have right now is this:
>
> > for indexing
> > in Post#define_index
> >    indexes post_content
> >    has labels(:id), :as => label_ids
>
> > for searching
> > i've tried all the following but the all return empty arrays
> > @posts =  Post.search "<some part of post_content of a post labeled
> > with label.id = 1>" , :with_all => {:label_ids => [1]}
> > or
> > @posts =  Post.search "<some part of post_content of a post labeled
> > with label.id = 1>" , :with => {:label_ids => 1}
>
> > note: regular searching (ie without filtering by label) works fine so
> > I know I'm indexing post_content right and can index and search, it's
> > just when I try to limit results to those with a certain label using
> > the label id attribute that I get no results
>
> > --
> > 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 
> > athttp://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