# In which case search will be fast

**URL:** <https://discuss.elastic.co/t/in-which-case-search-will-be-fast/7741>\
**Category:** Elasticsearch\
**Created:** [May 17, 2012, 1:01pm UTC](https://discuss.elastic.co/t/in-which-case-search-will-be-fast/7741 "2012-05-17T13:01:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andavar](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@andavar](https://discuss.elastic.co/u/andavar)\
**Post date:** [May 17, 2012, 1:01pm UTC](https://discuss.elastic.co/t/in-which-case-search-will-be-fast/7741/1 "2012-05-17T13:01:46Z")

</div>

Dear ElasticSearchUser,  
Please advise me what is the difference between these scenario

1. client.prepareSearch("indexname").setQuery(QueryBuilders.filteredQuery(qb, fb))

2. client.prepareSearch("indexname").setQuery(qb).setFilter(fb)

Regards,  
LP

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 20, 2012, 7:47pm UTC](https://discuss.elastic.co/t/in-which-case-search-will-be-fast/7741/2 "2012-05-20T19:47:38Z")

</div>

The filteredQuery option will be faster, the option to set a filter on the  
search request is there when facets are used.

On Thu, May 17, 2012 at 3:01 PM, andavar [andavar\_laxman@rediffmail.com](mailto:andavar_laxman@rediffmail.com)wrote:

> Dear ElasticSearchUser,  
> Please advise me what is the difference between these scenario  
> \*  
> 1.  
> client.prepareSearch("indexname").setQuery(QueryBuilders.filteredQuery(qb,  
> fb))
> 
> 1. client.prepareSearch("indexname").setQuery(qb).setFilter(fb)\*
> 
> Regards,  
> LP
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/In-which-case-search-will-be-fast-tp3999027.html](http://elasticsearch-users.115913.n3.nabble.com/In-which-case-search-will-be-fast-tp3999027.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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/in-which-case-search-will-be-fast/7741/3 "2017-07-06T03:28:01Z")

</div>


