Skip to content

Pagination not working more than once #956

Closed
@ivmarkp

Description

@ivmarkp

Slicing seems to work only once for me. After debugging, I found that the size is set to 0 in s even though I assign it to 1000 in the while loop below. Is this a bug I just found or something's wrong with my code itself?

s = Search(using=es, index=properties.es_index) \
     .query("match_phrase", field= text)

lefthits = s.count()
start = 0
s = s[0:1000]
results = s.execute()

count = 0
while len(results.hits.hits) > 0:
  for hit in results:
    count += 1
  print(count)
  lefthits = results.hits.total - count
  if lefthits > 0:
    start += 1000
    s = s[start:1000]
    results = s.execute()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions