My unit/integration tests includes tests for search functionality.
My idea is to have empty search index before each test. So, I\'m trying to remove al
My idea is to have empty search index before each test
So create a new index at the start of the test, don't re-use the old one. You're guaranteed an empty one then. In the tests's teardown, you can then delete the test index.
It there any way to commit last changes, or make an lock until all data will be written?
No, ElasticSearch has no transactions or locking.
If you don't want to create new index each time, then try adding a loop which checks to see if the index is empty, then waits and tries again, until it is.