# Need help to write fast query

**URL:** <https://discuss.elastic.co/t/need-help-to-write-fast-query/287791>\
**Category:** Elasticsearch\
**Tags:** kql-kibana-query-language\
**Created:** [October 27, 2021, 11:45am UTC](https://discuss.elastic.co/t/need-help-to-write-fast-query/287791 "2021-10-27T11:45:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsmerajesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itsmerajesh/32/77793_2.png) [@itsmerajesh](https://discuss.elastic.co/u/itsmerajesh)\
**Post date:** [October 27, 2021, 11:45am UTC](https://discuss.elastic.co/t/need-help-to-write-fast-query/287791/1 "2021-10-27T11:45:00Z")

</div>

Hi all,  
Consider, I have 1000phrases(Example of phrases can be: 1. "Hello",2. "What are you doing", 3. "automatically debit",...etc) as a1, a2, a3.......a1000. now I need to write a query in java for the ES database, the query should replicate the below:  
There is a main base phrase, which I need to include with all other 1000 phrases while querying, for example:  
consider the base phrase as A. now my query should replicate as:  
{  
A and a1,  
A and a2,  
A and a3,  
.  
.  
.  
A and a1000  
} whole comes within one query. i have around 10,00,000 documents. i wrote a query but its taking very long time. appropriately more than 40seconds.  
Anyone could help me?

---

<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:** [November 24, 2021, 11:45am UTC](https://discuss.elastic.co/t/need-help-to-write-fast-query/287791/2 "2021-11-24T11:45:16Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
