Search problem

Tom Ha
Tue, 01 Apr 2008 22:58:04 -0000

Hi there,

I''ve been spending hours trying to figure out how to do this ferret
query correctly, but it just won''t work...

The final ferret query should simply look like this:

  country: "United Kingdom"
  (it needs the "" because it''s a "PhraseQuery")

I thought the controller should look like this...

a)
  query = @query =
"country:"+''"''+@search.country}+''"''
if
@search.country
  @results = User.find_by_contents(query)

...or...

b)
  query = @query =
"country:"+"\""+@search.country}+"\"" if
@search.country
  @results = User.find_by_contents(query)

...or...

c)
  query = @query = "country:\"#{@search.country}\"" if
@search.country
  @results = User.find_by_contents(query)

...but the search doesn''t get the correct result. (In fact, it
doesn''t
even get a result with only "United" in the "country" column
- I
tried...)

When I look at the "@query.inspect", it reads for all 3 cases:

  "country:\"United Kingdom\""

What am I doing wrong??? What is the correct controller syntax?

Thank you very much for your help!
Tom
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---