# Slowly term queries

**URL:** https://discuss.elastic.co/t/slowly-term-queries/241591
**Category:** Elasticsearch
**Created:** [July 17, 2020, 7:04am UTC](https://discuss.elastic.co/t/slowly-term-queries/241591 "2020-07-17T07:04:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![liron\_gofberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/liron_gofberg/32/59823_2.png) [@liron\_gofberg](https://discuss.elastic.co/u/liron_gofberg)
#### Post date: [July 17, 2020, 7:04am UTC](https://discuss.elastic.co/t/slowly-term-queries/241591/1 "2020-07-17T07:04:06Z")

</div>

Hi,

I’m using scan function in Python to retrieve more than 10000 results  
There are only filter queries  
I search only for terms  
There is no aggregation, only simple term queries  
I executed two queries with the same structure  
both of them return 20 documents but in different timing  
Both of them run on the same specific shard  
Because of the routing (not in the same time)  
But the search performance in one are much better than the second  
The difference between them is one term field

What could make the difference

Query 1

”blabla”:”4”  
“gg”:”67”

Query 2

”blabla”:”4”  
“kk”:”89”

Thanks,  
Liron

---

<div class="post-metadata">

### Author: ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)
#### Post date: [July 17, 2020, 9:46pm UTC](https://discuss.elastic.co/t/slowly-term-queries/241591/2 "2020-07-17T21:46:59Z")

</div>

I am not familiar with scan function. How do these query look in Elasticsearch DSL? Is `10000` a size parameter? Are these AND queries?

---

<div class="post-metadata">

### Author: ![liron\_gofberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/liron_gofberg/32/59823_2.png) [@liron\_gofberg](https://discuss.elastic.co/u/liron_gofberg)
#### Post date: [July 17, 2020, 10:14pm UTC](https://discuss.elastic.co/t/slowly-term-queries/241591/3 "2020-07-17T22:14:50Z")

</div>

Hi,

thanks for answering

something like that  
just with must clause inside the filter clause  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/e/deea4077eb1d2876592c202ae0b4f9e54a29a4f0.png)

but scan is not the problem because one query run fast and the second run very slowly  
the difference is just one term in the filter

size is 1000

only AND queries because I'm using must clause  
I specify only 2 terms in must clause

---

<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: [August 14, 2020, 10:14pm UTC](https://discuss.elastic.co/t/slowly-term-queries/241591/4 "2020-08-14T22:14:54Z")

</div>

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