Ah, I understand now. So why not use the hash, though? -- Pat
On 29/07/2009, at 9:50 AM, elijah wrote: > > On Jul 28, 6:27 am, Pat Allan <[email protected]> wrote: >> Sphinx can't (yet) filter on strings. That's upcoming in 0.9.10, >> apparently. >> The following syntax is fine: >> Tree.search 'sapling', :with => {:variety => [1, 2, 3]} > > Yes, in fact my example was overly simple. Currently I only use this > on numbers in multi attributes. Sorry for the confusion. > >> Err, I'm more than a little surprised that code works. >> From a Sphinx API perspective, you can't send through arrays of >> arrays, or strings, when it comes to filters. So, if you're getting >> the right results, I'd personally put it down to some fluke in >> Sphinx. >> Don't make any assumptions on this working for production sites. > > Yes, :with expects a hash, but if you give it an array it works too, > because of the way the Riddle filters are created in search.rb. > > If you have this: > > Tree.search 'sapling', :with => [['variety', [1, 2]], ['variety', > [3]]] > > The filters are generated here: > > client.filters += options[:with].collect { |attr,val| > Riddle::Client::Filter.new attr.to_s, filter_value(val) > } if options[:with] > > And this will generate two riddle filters on the attribute 'variety', > one with the filter value of [1,2] and one with the filter value of > [3]. This creates a query where both filters must match for all the > documents returned. If you pass a hash, then you can only have one > filter on variety, because it must be a unique key. > > I guess this behavior was unintentional on your part, but I like it! > It is certainly a valid thing to do in sphinx. > > -elijah > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
