# Ferret query

**URL:** <https://www.ruby-forum.com/t/ferret-query/196632>\
**Category:** Rails\
**Created:** [April 2, 2008, 10:00am UTC](https://www.ruby-forum.com/t/ferret-query/196632 "2008-04-02T10:00:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [April 2, 2008, 10:00am UTC](https://www.ruby-forum.com/t/ferret-query/196632/1 "2008-04-02T10:00:13Z")

</div>

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:”+’"‘removed\_email\_address@domain.invalid}+’"’ if  
@search.country  
@results = User.find\_by\_contents(query)

…or…

b)  
query = @query = “country:”+""“removed\_email\_address@domain.invalid}+”"" 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
