# How to delete document from the same index in 3 elasticsearch instances

**URL:** <https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437>\
**Category:** Elasticsearch\
**Created:** [April 4, 2019, 2:39pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437 "2019-04-04T14:39:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 4, 2019, 2:39pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/1 "2019-04-04T14:39:49Z")

</div>

Hello ,

i have one index (same structure) in 3 elasticsearch instances (1,2,3) and all works fine , my issue is : when i delete a document from the index in ES instance 1 , i want also delete the same document from the index in other ES instances (2,3) or how i can make a query in ES instance 1 to get all documents that exists in ES instance 2 and 3 and dosn't exists in ES instance 1 (where i execute my query).

Best Regards!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 4, 2019, 5:47pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/2 "2019-04-04T17:47:31Z")

</div>

What do you mean by "instance"? A node? A cluster?  
I have hard time to understand your question. Could you be more specific?

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 8:36am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/3 "2019-04-05T08:36:11Z")

</div>

Hello @dadoonet,

yes i mean a node (this is the terminology in elasticsearch website : Any time that you start an **instance** of Elasticsearch, you are starting a _ **node** _)

so i have 3 nodes , each node in a different server. and after delete document from node 1 i want to delete the same documents from the other nodes or how i can query all doocuments in node 2 or 3 that not exists in node 1

Thnaks for your time.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2019, 9:21am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/4 "2019-04-05T09:21:55Z")

</div>

Are those nodes part of the same cluster? What gives:

```auto
GET /_cat/nodes?v

```

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 9:54am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/5 "2019-04-05T09:54:38Z")

</div>

no , not the same cluster

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2019, 10:09am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/6 "2019-04-05T10:09:56Z")

</div>

Why not?

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 10:57am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/7 "2019-04-05T10:57:12Z")

</div>

this is the architecture that i found in the project... 😕

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2019, 11:10am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/8 "2019-04-05T11:10:07Z")

</div>

Are those 3 nodes in the same datacenter? In the same region?

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 12:06pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/9 "2019-04-05T12:06:55Z")

</div>

yes in 3 servers (vm )and i can accees to documents using curl -XGET '[http://IP:9200/book/books/564](http://IP:9200/book/books/564)'?pretty , i can for example get document in node 3 from node 1.. but i want to know which documents exists in n1 and not in n2 or n3 something like IN NOT IN in sql

BEst Regards.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2019, 12:34pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/10 "2019-04-05T12:34:11Z")

</div>

You can't do that easily. You need to do that manually.

But I still don't understand the use case to be honest. Why not 3 nodes within the same cluster? Do they hold different data?

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 2:12pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/11 "2019-04-05T14:12:52Z")

</div>

in the fact the use cas is that there is a web application deployed in 3 servers (vm) (load balancing ..)and the webapp is connected to the ES node that is deplyoed in the same vm , the issue is when the app in the vm 1 for example delete a document i want to keep the other nodes updated i mean delete the document from the other nodes

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 5, 2019, 2:14pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/12 "2019-04-05T14:14:10Z")

</div>

That makes no sense and my advice is that you fix this architecture design.

But if you want to do it, you need to manually call every single instance yourself to remove the document everywhere.

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 5, 2019, 3:55pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/13 "2019-04-05T15:55:28Z")

</div>

Ok thank you for your advice

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 8, 2019, 9:47am UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/14 "2019-04-08T09:47:49Z")

</div>

Hello @dadoonet

i got the OK to change the design of this architecture do you have please any suggestions to keep all the 3 nodes updated and have the same documents even they are installed in different servers.

Best regards.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 8, 2019, 1:13pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/15 "2019-04-08T13:13:43Z")

</div>

Just use a standard deployment. Make them all form a cluster and you're done.

For existing data, you won't be able to keep all 3 data. I suppose that one of the node has all the data anyway.

If so, just stop the 2 other data nodes, restart them as part of the cluster. Read [https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html) and specifically [https://www.elastic.co/guide/en/elasticsearch/reference/current/network.host.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/network.host.html)

Start the first node and check that it joined the cluster by running on any node:

```auto
GET /_cat/nodes?v

```

You should see both nodes.  
Once done, do the same thing with the 3rd node.

Once done, if you really want to have data on all nodes, change the number of replicas for all indices to `2`:

```auto
PUT /twitter/_settings
{
    "index" : {
        "number_of_replicas" : 2
    }
}

```

May be this could work:

```auto
PUT /_all/_settings
{
    "index" : {
        "number_of_replicas" : 2
    }
}

```

HTH

---

<div class="post-metadata">

**Author:** ![ali1](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@ali1](https://discuss.elastic.co/u/ali1)\
**Post date:** [April 8, 2019, 1:56pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/16 "2019-04-08T13:56:44Z")

</div>

Thank ou so much @dadoonet , i will follow all of thes steps...

Regards!

---

<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:** [May 6, 2019, 1:57pm UTC](https://discuss.elastic.co/t/how-to-delete-document-from-the-same-index-in-3-elasticsearch-instances/175437/17 "2019-05-06T13:57:01Z")

</div>

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