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.

Using the scan method: how to add preserve_order=True?

See original GitHub issue

I need to scan through all the documents in a DocType, while preserving the order in which they were added to it.

I logically turned to the scan method, but that does not preserve the order. The elasticsearch-py scan helper method can take a preserve_order argument. But I can’t figure out how to use it with elasticsearch-dsl-py.

Is it possible?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
honzakralcommented, Nov 15, 2017

@jaisharma639 regular sorting should work for you then: Search().sort('my_field').param(preserve_order=True).scan()

5reactions
honzakralcommented, May 12, 2015

You can do it by specifying params method, anything passed there will be used as a kwargs when calling the underlying method (client.search or, in this case, helpers.scan):

s = Search().params(preserve_order=True)
for d in s.scan(): print(d)

hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserver Order in Testng - Selenium Easy
By default preserve-order is set to 'False', which executes your tests in Alphabetical order of your test/method names. When you set preserve-order to...
Read more >
Preserve-order at method level - Google Groups
In TestNG,how do we use preserve-order at the method level? I want methods to be executed in the sequence I have specified. Using...
Read more >
Working with scans in DynamoDB - AWS Documentation
You first use Scan with ConsistentRead set to true to obtain a consistent copy of the data in the table. During the Scan...
Read more >
scan - fastlane docs
The easiest way to run tests of your iOS and Mac app. scan makes it easy to run tests of your iOS and...
Read more >
How To Set Test Case Priority In TestNG With Selenium
Now ideally, the test methods should have been executed in alphabetical order since they all had a default priority of 0 assigned. So, ......
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