Filter certain docs


(Brandon Hilkert) #1

I'm searching some users, and want to only search within those that I'm
connected to on Facebook. As part of the search query, I'm sending in an
array of my connections, but I'm not getting back any results. Should I be
using something other than filter :terms?

{ :filter=>{ :terms=>{ :fb_user_id => ["120139", "503009"....] } } }

The issues is that fb_user_id is a string field within each user and most
examples I see have the terms field that you would search against being an
Array like "Tags".

Thanks,
Brandon


(Brandon Hilkert) #2

I realized I'm having trouble because I have 2 filters, and by default,
they are "and", and to get good results, I need them to be "or".

What's the difference between doing a "filtered" query (
http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html)
and applying a filter for the people we know, and just adding a filter
clause to a single query with
http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html?

On Wednesday, May 16, 2012 8:28:44 PM UTC-4, Brandon Hilkert wrote:

I'm searching some users, and want to only search within those that I'm
connected to on Facebook. As part of the search query, I'm sending in an
array of my connections, but I'm not getting back any results. Should I be
using something other than filter :terms?

{ :filter=>{ :terms=>{ :fb_user_id => ["120139", "503009"....] } } }

The issues is that fb_user_id is a string field within each user and most
examples I see have the terms field that you would search against being an
Array like "Tags".

Thanks,
Brandon


(system) #3