question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get all results back from search?

See original GitHub issue

After executing a search, the Search hits.total is over 9000. However, when I check the length of hits.hits it is only 10:

>>> client = Elasticsearch(['http://nightly.apinf.io:14002'])
>>> search = Search(using=client)
>>> results = search.execute()
>>> results.hits.total
9611
>>> len(results.hits.hits)
10

How do I get back all 9611 search results?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

9reactions
honzakralcommented, Nov 14, 2018

@abhimanyu3 sorry for the late response, by default the scan return things unordered. To have it respect the sort you need to do s = s.params(preserve_order=True) before calling s.scan() (see [0] for details).

0 - https://elasticsearch-py.readthedocs.io/en/master/helpers.html#scan

4reactions
honzakralcommented, Sep 18, 2017

Also, if you want to retrieve all the hits, there is a specialized method called scan that will iterate over all the hits, not just the top N. That is the recommended way if you want to unload all of the documents above lets say a few hundred or thousand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

elasticsearch - How to get all the values from an search result
I am new to Elastic Search. Is there any way to get all the search results for a search keyword? Elastic Search is...
Read more >
How do I make search return results that actually contain ...
I get results containing the word "search" and a few of them even contain the word "words", but I can't see any that...
Read more >
SharePoint Search – how to return all results
This can be done by keeping the current row index value(which is the last row of the current result set), looping through the...
Read more >
How do I get all results from large requests to the Search ...
I'm trying to request day-by-day metrics for a large number of pages via the Search Console API. When trying to do this in...
Read more >
How to Get More Google Search Results Per Page - YouTube
How to Get More Google Search Results Per Page.Google puts all the information in the world literally at the tips of your fingers....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found