How to paginate results from Elasticsearch DSL in Python

duality_

I'm using Elasticsearch DSL and I would like to paginate through the results. To do that, I need to know the total number of results in the search. How should I best do that?

Do I do one search, then execute twice, one generally for the .hits.total and the other sliced for items? Something like this:

response = Link.search().filter("term", run_id=run_id)
total = response.execute().hits.total
links = response[start:end].execute()
Cari

Try this:

dsl = Link.search().filter("term", run_id=run_id)
response = dsl[start:end].execute()
links = response.hits.hits
total = response.hits.total

... only hits ElasticSearch once.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to paginate search results from text file

From Dev

How to Get All Results from Elasticsearch in Python

From Dev

How to paginate search results in Django?

From Dev

Elasticsearch DSL query - Get all matching results

From Dev

how to log or print python elasticsearch-dsl query that gets invoked

From Dev

How to select specific fields in elasticsearch-dsl python

From Dev

how to exclude meta data from elasticsearch results?

From Dev

How to paginate query results ordered in descending order

From Dev

How to paginate query results ordered in descending order

From Dev

How to paginate objects from a relationship

From Dev

How to group results in elasticsearch?

From Dev

Elasticsearch DSL limit filter returning more results than specified

From Dev

Elasticsearch DSL query from an SQL statement

From Dev

How to exclude unrelated search results from django-haystack and Elasticsearch?

From Dev

Python elasticsearch-dsl django pagination

From Dev

aggregate a field in elasticsearch-dsl using python

From Dev

Elasticsearch dsl python, natural key for document?

From Dev

How to specify the document type when using elasticsearch_dsl (Python)? Similarly, how to specify a few indices?

From Dev

How to make urlib return an array in python - Parse the results of a call to elasticsearch?

From Java

How to use ElasticSearch JSON DSL in Java?

From Dev

How to rewrite ElasticSearch DSL query with the Java API

From Dev

How to write java code for elasticsearch DSL query

From Dev

How set ignore_malformed in index level when creating an index through ElasticSearch DSL python wrapper?

From Dev

How paginate results in Datatables properly (ajax, server-side)?

From Dev

How to use KNPPaginatorBundle to paginate results using Doctrine Repository?

From Dev

Creating DataFrame from ElasticSearch Results

From Dev

Retrieve data from elasticsearch results

From Dev

Paginate Results of Model Laravel

From Dev

How to paginate Files from a Folder using cakephp

Related Related

  1. 1

    how to paginate search results from text file

  2. 2

    How to Get All Results from Elasticsearch in Python

  3. 3

    How to paginate search results in Django?

  4. 4

    Elasticsearch DSL query - Get all matching results

  5. 5

    how to log or print python elasticsearch-dsl query that gets invoked

  6. 6

    How to select specific fields in elasticsearch-dsl python

  7. 7

    how to exclude meta data from elasticsearch results?

  8. 8

    How to paginate query results ordered in descending order

  9. 9

    How to paginate query results ordered in descending order

  10. 10

    How to paginate objects from a relationship

  11. 11

    How to group results in elasticsearch?

  12. 12

    Elasticsearch DSL limit filter returning more results than specified

  13. 13

    Elasticsearch DSL query from an SQL statement

  14. 14

    How to exclude unrelated search results from django-haystack and Elasticsearch?

  15. 15

    Python elasticsearch-dsl django pagination

  16. 16

    aggregate a field in elasticsearch-dsl using python

  17. 17

    Elasticsearch dsl python, natural key for document?

  18. 18

    How to specify the document type when using elasticsearch_dsl (Python)? Similarly, how to specify a few indices?

  19. 19

    How to make urlib return an array in python - Parse the results of a call to elasticsearch?

  20. 20

    How to use ElasticSearch JSON DSL in Java?

  21. 21

    How to rewrite ElasticSearch DSL query with the Java API

  22. 22

    How to write java code for elasticsearch DSL query

  23. 23

    How set ignore_malformed in index level when creating an index through ElasticSearch DSL python wrapper?

  24. 24

    How paginate results in Datatables properly (ajax, server-side)?

  25. 25

    How to use KNPPaginatorBundle to paginate results using Doctrine Repository?

  26. 26

    Creating DataFrame from ElasticSearch Results

  27. 27

    Retrieve data from elasticsearch results

  28. 28

    Paginate Results of Model Laravel

  29. 29

    How to paginate Files from a Folder using cakephp

HotTag

Archive