Forum: Ruby on Rails Ultrasphinx: adding field_name in search query

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E5d4db2f53bec777e0d25acbeb3f706e?d=identicon&s=25 Veera Sundaravel (veeraa2003)
on 2008-12-19 11:59
Hi all,

I want to search for a keyword in a particular field, for example say I
want to search for the keyword "rails" in the field title so how can I
include the field_name in query string.

s=Ultrasphinx::Search.new(:query => "@title rails")

or

s=Ultrasphinx::Search.new(:query => "title: rails")

or

s=Ultrasphinx::Search.new(:query => "@title: rails")


Thanks in advance,
T.Veeraa.
E5d4db2f53bec777e0d25acbeb3f706e?d=identicon&s=25 Veera Sundaravel (veeraa2003)
on 2008-12-20 05:41
Veera Sundaravel wrote:
> Hi all,
>
> I want to search for a keyword in a particular field, for example say I
> want to search for the keyword "rails" in the field title so how can I
> include the field_name in query string.
>
> s=Ultrasphinx::Search.new(:query => "@title rails")
>
> or
>
> s=Ultrasphinx::Search.new(:query => "title: rails")
>
> or
>
> s=Ultrasphinx::Search.new(:query => "@title: rails")
>
>
> Thanks in advance,
> T.Veeraa.

finally I found

s=Ultrasphinx::Search.new(:query => "title: rails")

above is the write syntax to include the field_name inside search query
as per the documentation.

But when you are using this for exact phrase match, it not working.

s=Ultrasphinx::Search.new(:query => 'title: "ruby on rails"')

am searching for the exact phrase "ruby on rails" in title field it
matches exact phrase, thats good, but when am trying the same phrase
with another field also returning the same result. Hence not its not
looking into the field what I specified.
This topic is locked and can not be replied to.