I would like to create a new index if not already there with Java API.
The appended way does not work because the map doesn't contain the
index even if it exists!?
Also the following index map is empty:
map = client.admin().cluster().state(new
ClusterStateRequest()).actionGet().getState().getMetaData().getIndices();
What am I doing wrong?? I need this for unit tests where automatic
index creation does not work in some cases, where I am querying before
indexing ...
I would like to create a new index if not already there with Java API.
The appended way does not work because the map doesn't contain the
index even if it exists!?
Also the following index map is empty:
map = client.admin().cluster().state(new
ClusterStateRequest()).actionGet().getState().getMetaData().getIndices();
What am I doing wrong?? I need this for unit tests where automatic
index creation does not work in some cases, where I am querying before
indexing ...
Yea, you should wait for the state to be recovered from the gateway (at least the simple one where indices are recreated).
If you try and create an index, it will block until the cluster is in such a state where the metadata has been recovered, and only then try and create that index. Then, you will either get an exception (that the index already exists) or success.
On Saturday, January 22, 2011 at 4:55 PM, Karussell wrote:
Putting the waitForYellowStatus before the ClusterHealthRequest seems
to solve this.
I would like to create a new index if not already there with Java API.
The appended way does not work because the map doesn't contain the
index even if it exists!?
Also the following index map is empty:
map = client.admin().cluster().state(new
ClusterStateRequest()).actionGet().getState().getMetaData().getIndices();
What am I doing wrong?? I need this for unit tests where automatic
index creation does not work in some cases, where I am querying before
indexing ...
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.