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

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!

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

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.

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

GET /_cat/nodes?v

no , not the same cluster

Why not?

this is the architecture that i found in the project... :confused:

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

yes in 3 servers (vm )and i can accees to documents using curl -XGET '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.

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?

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

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.

Ok thank you for your advice

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.

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 and specifically 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:

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:

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

May be this could work:

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

HTH

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

Regards!

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