# Isolate parallel requests to Elasticsearch

**URL:** <https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996>\
**Category:** Elasticsearch\
**Created:** [June 15, 2021, 12:23pm UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996 "2021-06-15T12:23:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daksh0225](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daksh0225/32/90336_2.png) [@daksh0225](https://discuss.elastic.co/u/daksh0225)\
**Post date:** [June 15, 2021, 12:23pm UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996/1 "2021-06-15T12:23:33Z")

</div>

Hi all,

I want to run a set of test classes for my application in parallel. Inside each of the test class, the functions make calls to elasticsearch. Currently the problem I am facing in running the tests in parallel is that when I query elasticsearch from say TestA, it may include documents which were inserted during TestB. In such a case the test would fail since the desired result should contain the documents corresponding to TestA only. So, I was wondering if there was a way to isolate the requests made to elasticsearch or create a sandbox of elasticsearch for each test class.

Currently I am looking for answers which support single node cluster.

Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2021, 11:19pm UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996/2 "2021-06-15T23:19:04Z")

</div>

Welcome to our community! 😃

The simplest way I can think to handle this would be to use different indices for each test. Is that possible?

---

<div class="post-metadata">

**Author:** ![daksh0225](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daksh0225/32/90336_2.png) [@daksh0225](https://discuss.elastic.co/u/daksh0225)\
**Post date:** [June 16, 2021, 9:49am UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996/3 "2021-06-16T09:49:47Z")

</div>

@warkolm Unfortunately, it is not possible to create new index for each test since some of the test may use some pre-existing index for their operations.

I am looking for a solution more on the lines with the following line of thought - I want to run a single instance of elasticsearch on localhost and treat it as multiple different instances such that the pre-existing indices are available across all the, let's say, "virtual" instances, but any new changes made are restricted to a particular "virtual" instance.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 17, 2021, 12:51am UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996/4 "2021-06-17T00:51:38Z")

</div>

The only way that'd make sense to do that is to use different indices.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 15, 2021, 12:52am UTC](https://discuss.elastic.co/t/isolate-parallel-requests-to-elasticsearch/275996/5 "2021-07-15T00:52:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
