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 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