@field won't accept multiple arguments

11 views
Skip to first unread message

dwickwire

unread,
Jul 6, 2011, 3:45:23 PM7/6/11
to Thinking Sphinx
Hello,

So sometimes I find myself searching with something like this

Project.search("@title \"some name\", @data_type \"Book
\"", :match_mode => :extended, :per_page => 20)


This method works great but when I add more than one data_type it
doesn't seem to work unless its using the conditions hash.

-- Doesn't work
Project.search("@title \"some name\", @data_type \"(Book | Audio)
\"", :match_mode => :extended, :per_page => 20)

-- Works
Project.search("@title \"some name\"", :conditions => {:data_type =>
"(Book | Audio)}, :match_mode => :extended, :per_page => 20)

Is the @field version limited somehow?

*I'm on TS 1.4.3

Jeremy Peterson

unread,
Jul 6, 2011, 9:11:26 PM7/6/11
to thinkin...@googlegroups.com
Derek,

You need to change your match mode.  Doing this will work in your project...

YourModel.search "@data_type book @title think", :match_mode => :extended

Sincerely,

Jeremy


--
You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
To post to this group, send email to thinkin...@googlegroups.com.
To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.


Pat Allan

unread,
Jul 6, 2011, 9:19:43 PM7/6/11
to thinkin...@googlegroups.com
I think it's more a query setup problem - as you're using the extended match mode in all examples. However, you want to quote each data type inside of the parentheses, instead of the other way around:

Project.search("@title \"some name\", @data_type (\"Book\" | \"Audio\")",


:match_mode => :extended, :per_page => 20)

Cheers

--
Pat

yekta

unread,
Jul 6, 2011, 11:02:31 PM7/6/11
to Thinking Sphinx
That did it,

So each data_type must be in its own set of quotes all within parens.

Thanks.

On Jul 6, 8:19 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> I think it's more a query setup problem - as you're using the extended match mode in all examples. However, you want to quote each data type inside of the parentheses, instead of the other way around:
>
>   Project.search("@title \"some name\", @data_type (\"Book\" | \"Audio\")",
>     :match_mode => :extended, :per_page => 20)
>
> Cheers
>
> --
> Pat
>
> On 07/07/2011, at 11:11 AM, Jeremy Peterson wrote:
>
>
>
>
>
>
>
> > Derek,
>
> > You need to change your match mode.  Doing this will work in your project...
>
> > YourModel.search "@data_type book @title think", :match_mode => :extended
>
> > Sincerely,
>
> > Jeremy
>
> > On Wed, Jul 6, 2011 at 2:45 PM, dwickwire <wickw...@gmail.com> wrote:
> > Hello,
>
> > So sometimes I find myself searching with something like this
>
> > Project.search("@title \"some name\", @data_type \"Book
> > \"", :match_mode => :extended, :per_page => 20)
>
> > This method works great but when I add more than one data_type it
> > doesn't seem to work unless its using the conditions hash.
>
> >  -- Doesn't work
> > Project.search("@title \"some name\", @data_type \"(Book | Audio)
> > \"", :match_mode => :extended, :per_page => 20)
>
> >  -- Works
> > Project.search("@title \"some name\"", :conditions => {:data_type =>
> > "(Book | Audio)}, :match_mode => :extended, :per_page => 20)
>
> > Is the @field version limited somehow?
>
> > *I'm on TS 1.4.3
>
> > --
> > You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> > To post to this group, send email to thinkin...@googlegroups.com.
> > To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/thinking-sphinx?hl=en.

Pat Allan

unread,
Jul 6, 2011, 11:05:50 PM7/6/11
to thinkin...@googlegroups.com
Yup - quotes are for exact phrases - so ("Book | Audio") would only match data types of "Book | Audio", instead of "Book" or "Audio".

--
Pat

Reply all
Reply to author
Forward
0 new messages