I have a web url api which serving by the elastic search.
- My web urls is https://data.emp.com/employees
- I have 50 employee(data) in my index
- On each scroll 7 employee will be adding take 7,14,21..49,50
- On each scroll 7 employee will appear first then 14 employees, ..49,50 employees
- My Api below URL is all 50 employees at one shot
def elastic_search():
"""
Return full search using match_all
"""
try:
full_search= es.search(index="employees",scroll = '2m',size = 10,body={ "query": {"match_all": {}}})
hits_search = full_search['hits']['hits']
return hits_search
except Exception as e:
logger.exception("Error" + str(e))
raise
I have modified above code like below
sid = search["_scroll_id"]
scroll_size = search['hits']['total']
scroll_size = scroll_size['value']
# Start scrolling
while (scroll_size > 0):
#print("Scrolling...")
page = es.scroll(scroll_id = sid, scroll = '1m')
#print("Hits : ",len(page["hits"]["hits"]))
# Update the scroll ID
sid = page['_scroll_id']
# Get the number of results that we returned in the last scroll
scroll_size = len(page['hits']['hits'])
search_text = page['hits']['hits']
print (search_text)
My api is throwing [] because my last search_text giving blank.
In the log it is printing each set of 7 employees. But My web url api is loading loading and last it showing blank page
Please help in updating in returning "hits_search" which is in elastic_search function