# Match all query not working elastic search

**URL:** <https://discuss.elastic.co/t/match-all-query-not-working-elastic-search/184507>\
**Category:** Logstash\
**Created:** [June 6, 2019, 7:14am UTC](https://discuss.elastic.co/t/match-all-query-not-working-elastic-search/184507 "2019-06-06T07:14:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smack\_Alpha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smack_alpha/32/43660_2.png) [@Smack\_Alpha](https://discuss.elastic.co/u/Smack_Alpha)\
**Post date:** [June 6, 2019, 7:14am UTC](https://discuss.elastic.co/t/match-all-query-not-working-elastic-search/184507/1 "2019-06-06T07:14:32Z")

</div>

I am writing a python program to get the data from the elastic search indices. I want to get the data based on the match query which i indicated is upto 25. I want the first 25 data's. The data's in my index is 10842. But it retrieves all the data from the index of the elastic search. I checked solution from here [matchall query for es](https://stackoverflow.com/questions/47722238/python-elasticsearch-helpers-scan-example) but it doesn't helped me. Help me with some solutions

Here's the code:

```
from elasticsearch import Elasticsearch
import elasticsearch.helpers

count = 0
host = 'localhost'
ind = 'apps'
doc_typ = "change_apps"
limit_count = 25

def elasticsearch_import(host,ind,doc_typ,count,limit_count,port=9200,query={},single_line=False,single_line_label="message"):
    data_count=count+limit_count
    print("Data to be get from Elastic Search: ",data_count)
    es = Elasticsearch()
    results = elasticsearch.helpers.scan(es,
    index=ind,
    doc_type=doc_typ,
    preserve_order=True,
    query={"query": {"match_all": {}},"from":count,"size":data_count})
    res=[]
    for i in results:
        res.append(i)
    #print("res",res)
    print("Data got from Elastic Search",len(res))
elasticsearch_import(host,ind,doc_typ,count,limit_count)

```

Output i got:

```
Data to be get from Elastic Search: 25
Data got from Elastic Search 10842

```

---

<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 4, 2019, 7:14am UTC](https://discuss.elastic.co/t/match-all-query-not-working-elastic-search/184507/2 "2019-07-04T07:14:40Z")

</div>

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