Error when create an index in two hosts


(Chanpiseth Ros) #1

Hi Teams, i have an error when i try to create an index in two hosts with php code, and this is an error message:

Exception : {"error":"IndexAlreadyExistsException[[sample] already exists]","status":400}

And this is my code php:

$hosts = [
1 => 'http://elasticsearch:9200',
2 => 'http://10.10.10.20:9200'
];
ClientBuilder::indices()->create($hosts);

Can anyone help me?


(David Pilato) #2

I don't understand PHP I'm afraid. What is it suppose to run behind the scene?

I don't see where the political index name is coming from in your code. Are you sure it's complete?


#3

A few questions just to clarify stuff...

  1. Are you trying to write to two hosts in the same cluster or are they separate clusters?
  2. What do you want to achieve by creating the indices on two different hosts?

(Chanpiseth Ros) #4

Yes, i want to achieve by crating the indices on two different hosts.


(andy_zhou) #5

the cluster output the same already exists see is or not?


(Christian Dahlqvist) #6

Indices are created per cluster, not host, so if these two nodes belong to the same cluster you only need to send the request to one of the nodes. Elasticsearch will then create the index and distribute shards across all nodes in the cluster.


(system) #7

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