With integer attributes, passing in an array of integers in a :with filter will 
match on ANY of those values. So:

  Model.search "foo", :with => {:industry_id => [1, 2]}

This will return all objects where a field contains 'foo', and with an industry 
id of either 1 or 2.

On 27/05/2013, at 8:32 PM, Treeninja wrote:

> Hi Pat!
> 
> Integer Attributes.
> 
> I have many industries and would like to do something like Agriculture (db id 
> = 1) or Metalurgy (db id = 2).
> 
> On Monday, May 27, 2013 12:48:24 PM UTC+2, Pat Allan wrote:
> Are we talking about fields containing numbers, or integer attributes?
> -- 
> Pat
> 
> On 27/05/2013, at 8:13 PM, Treeninja wrote:
> 
> > How did you do it with integers?
> > 
> > Thanks.
> > 
> > On Wednesday, January 30, 2013 11:06:15 PM UTC+1, Matt Bilbow wrote:
> > nevermind I was being a dumbass, thanks Pat
> > 
> > On Thursday, 10 June 2010 13:50:16 UTC+1, Pat Allan wrote:
> > Great :)
> > -- 
> > Pat
> > 
> > On 10/06/2010, at 7:06 PM, badnaam wrote:
> > 
> > > That did it!!
> > > 
> > > Thanks.
> > > 
> > > On Jun 9, 4:36 am, Pat Allan <[email protected]> wrote:
> > >> Okay, what about the following:
> > >> 
> > >> ThinkingSphinx.search :conditions => {:city => '("San Jose" | "San 
> > >> Francisco")'}
> > >> 
> > >> Note the single and double quotes.
> > >> 
> > >> --
> > >> Pat
> > >> 
> > >> On 09/06/2010, at 6:16 PM, badnaam wrote:
> > >> 
> > >>> xxx - San Francisco
> > >>> yyy - San Jose
> > >> 
> > >>> Both ThinkingSphinx.search :conditions => {:city => "(xxx | yyy)"} and
> > >>> ThinkingSphinx.search :conditions => {:city => "(yyy | xxxx)"}
> > >> 
> > >>> return a single record corresponding to "yyyy". There should be two
> > >>> record returned one each.
> > >> 
> > >>> Thanks
> > >> 
> > >>> On Jun 8, 12:32 am, Pat Allan <[email protected]> wrote:
> > >>>> That's pretty much the answer I was looking for... two questions:
> > >> 
> > >>>> - What are xxx and yyy?
> > >>>> - What happens if you just do the following search:
> > >> 
> > >>>> ThinkingSphinx.search :conditions => {:city => "(xxx | yyy)"}
> > >> 
> > >>>> --
> > >>>> Pat
> > >> 
> > >>>> On 08/06/2010, at 4:08 AM, badnaam wrote:
> > >> 
> > >>>>> I am trying to allows the user to filter through the searches i.e. A
> > >>>>> typical use case would be.
> > >> 
> > >>>>> 1 - User searches for "abc" near zip code 10000 within 10 miles
> > >>>>> 2 - I present the initial search results and all the facets returned
> > >>>>> as check boxes i.e. categories, articles categories and city these
> > >>>>> records are associated with
> > >>>>> 3 - User might select one or more of these facets for further
> > >>>>> filtering. If it's a class facets I construct the "classes" array if
> > >>>>> it's a combination of other facets (i.e. user select two cities xxx
> > >>>>> and yyy) I construct a condition hash and I expect results that
> > >>>>> contain xxx OR yyy cities.
> > >> 
> > >>>>> Here is the actual query my application issues..
> > >> 
> > >>>>> ThinkingSphinx.facets "", :with=>{"@geodist"=>0.0..16093.44,
> > >>>>> "class_crc"=>3448190970}, :conditions=>{"city"=>"(xxx |
> > >>>>> yyy)"}, :geo=>[0.658336879619334,
> > >>>>> -2.13225004421321], :class_facet=>true, :latitude_attr=>:lat, 
> > >>>>> :classes=>nil, :page=>1, :per_page=>nil, :longitude_attr=>:lng, 
> > >>>>> :all_facets=>true
> > >> 
> > >>>>> Does this answer your question?
> > >> 
> > >>>>> On Jun 7, 2:43 am, Pat Allan <[email protected]> wrote:
> > >>>>>> I'm really not sure why this isn't working... but let's start with 
> > >>>>>> real data - what's the actual query you're searching for?
> > >> 
> > >>>>>> And, what are you trying to get from the query? Not the specific 
> > >>>>>> objects, but the reason for making this search request.
> > >> 
> > >>>>>> --
> > >>>>>> Pat
> > >> 
> > >>>>>> On 07/06/2010, at 12:16 PM, badnaam wrote:
> > >> 
> > >>>>>>> Here is the irb output, it seems it doesny even query my merchant
> > >>>>>>> model, just queries the article model.
> > >> 
> > >>>>>>> here is the define index for them
> > >> 
> > >>>>>>> http://pastie.org/994460
> > >> 
> > >>>>>>>>> ThinkingSphinx.facets  :all_facets => true, :conditions => {:city 
> > >>>>>>>>> => "(xxxx | yyyy)"}
> > >>>>>>> Sphinx   Querying: '@city (xxxx | yyyy)'
> > >>>>>>> Sphinx (0.005233s)   Found 1 results
> > >>>>>>> Article Load (0.2ms)   SELECT * FROM `articles` WHERE
> > >>>>>>> (`articles`.`id` IN (1))
> > >>>>>>> Sphinx   Querying: '@city (xxxx | yyyy)'
> > >>>>>>> Sphinx (0.005373s)   Found 1 results
> > >>>>>>> Article Load (0.2ms)   SELECT * FROM `articles` WHERE
> > >>>>>>> (`articles`.`id` IN (1))
> > >>>>>>> ArticleTag Load (1.3ms)   SELECT * FROM `article_tags` WHERE
> > >>>>>>> (`article_tags`.`id` = 4)
> > >>>>>>> Sphinx   Querying: '@city (xxxx | yyyy)'
> > >>>>>>> Sphinx (0.004669s)   Found 1 results
> > >>>>>>> Article Load (0.1ms)   SELECT * FROM `articles` WHERE
> > >>>>>>> (`articles`.`id` IN (1))
> > >>>>>>> Sphinx   Querying: '@city (xxxx | yyyy)'
> > >>>>>>> Sphinx (0.004139s)   Found 0 results
> > >> 
> > >>>>>>> On Jun 6, 7:11 pm, badnaam <[email protected]> wrote:
> > >>>>>>>> Pat - that doesnt work.
> > >> 
> > >>>>>>>> On Jun 5, 7:44 pm, Pat Allan <[email protected]> wrote:
> > >> 
> > >>>>>>>>> Try that last one (with the parentheses inside the string), 
> > >>>>>>>>> without an explicit match mode:
> > >> 
> > >>>>>>>>> ThinkingSphinx.facets(
> > >>>>>>>>> :all_facets => true,
> > >>>>>>>>> :conditions => {:city => "(xxx | yyy)"}
> > >>>>>>>>> )
> > >> 
> > >>>>>>>>> --
> > >>>>>>>>> Pat
> > >> 
> > >>>>>>>>> On 06/06/2010, at 5:40 AM, badnaam wrote:
> > >> 
> > >>>>>>>>>> result1 = ThinkingSphinx.facets  :all_facets => true, 
> > >>>>>>>>>> :conditions =>
> > >>>>>>>>>> {:city => "(xxx | yyy)"}, :match_mode => :boolean #> no luck 
> > >>>>>>>>>> either
> > >> 
> > >>>>>>>>>> On Jun 5, 12:34 pm, badnaam <[email protected]> wrote:
> > >>>>>>>>>>>> result1 = ThinkingSphinx.facets  :all_facets => true, 
> > >>>>>>>>>>>> :conditions =>
> > >>>>>>>>>>>> {:city => ("xxx: | "yyy")} #=> throws error NoMethodError: 
> > >>>>>>>>>>>> undefined method `|' for "yyy":String
> > >> 
> > >>>>>>>>>>> On Jun 5, 12:33 pm, badnaam <[email protected]> wrote:
> > >> 
> > >>>>>>>>>>>> Thanks Pat. That does not work though..
> > >> 
> > >>>>>>>>>>>> result1 = ThinkingSphinx.facets  :all_facets => true, 
> > >>>>>>>>>>>> :conditions =>
> > >>>>>>>>>>>> {:city => ("xxx | yyy")} #=> doesn't work
> > >>>>>>>>>>>> result1 = ThinkingSphinx.facets  :all_facets => true, 
> > >>>>>>>>>>>> :conditions =>
> > >>>>>>>>>>>> {:city => ("xxx")} #=> 1 result--correct
> > >>>>>>>>>>>> result1 = ThinkingSphinx.facets  :all_facets => true, 
> > >>>>>>>>>>>> :conditions =>
> > >>>>>>>>>>>> {:city => ("yyy")} #=> 1 result correct
> > >> 
> > >>>>>>>>>>>> this is on irb console.
> > >> 
> > >>>>>>>>>>>> What am I doing wrong?
> > >> 
> > >>>>>>>>>>>> On Jun 4, 10:27 pm, Pat Allan <[email protected]> 
> > >>>>>>>>>>>> wrote:
> > >> 
> > >>>>>>>>>>>>> You'll need to join the values together yourself:
> > >> 
> > >>>>>>>>>>>>> :city => "(#{a} | #{b})"
> > >> 
> > >>>>>>>>>>>>> --
> > >>>>>>>>>>>>> Pat
> > >> 
> > >>>>>>>>>>>>> On 05/06/2010, at 9:13 AM, badnaam wrote:
> > >> 
> > >>>>>>>>>>>>>> Is it possible to do a condition like
> > >> 
> > >>>>>>>>>>>>>> :conditon => {:city => [a, b]}  ?
> > >> 
> > >>>>>>>>>>>>>> city is a field not an index. if this wont work  (it doesnt 
> > >>>>>>>>>>>>>> actually),
> > >>>>>>>>>>>>>> what other option do I have?
> > >> 
> > >>>>>>>>>>>>>> Thanks
> > >> 
> > >>>>>>>>>>>>>> --
> > >>>>>>>>>>>>>> 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 
> > >>>>>>>>>> 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 
> > >>>>>>> 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 
> > >>>>> 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 
> > >>> 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.
> > >
> > 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Thinking Sphinx" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >  
> >  
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  



-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to