# Filter certain docs

**URL:** <https://discuss.elastic.co/t/filter-certain-docs/7733>\
**Category:** Elasticsearch\
**Created:** [May 17, 2012, 12:28am UTC](https://discuss.elastic.co/t/filter-certain-docs/7733 "2012-05-17T00:28:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Hilkert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_hilkert/32/2182_2.png) [@Brandon\_Hilkert](https://discuss.elastic.co/u/Brandon_Hilkert)\
**Post date:** [May 17, 2012, 12:28am UTC](https://discuss.elastic.co/t/filter-certain-docs/7733/1 "2012-05-17T00:28:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brandon\_Hilkert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_hilkert/32/2182_2.png) [@Brandon\_Hilkert](https://discuss.elastic.co/u/Brandon_Hilkert)\
**Post date:** [May 17, 2012, 1:38am UTC](https://discuss.elastic.co/t/filter-certain-docs/7733/2 "2012-05-17T01:38:54Z")

</div>

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 (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](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  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:28am UTC](https://discuss.elastic.co/t/filter-certain-docs/7733/3 "2017-07-06T03:28:27Z")

</div>


