Best practice to check if mapping exists?


(Alexander Kley) #1

Hi guys,

if I'll check mapping exists, i can do this in many ways, right?

First:
esClient.admin().cluster().prepareState().setFilterIndices(index.toLowerCase()).get().getState().getMetaData().index(index).mapping(type.toLowerCase();

Second:
esClient.admin().indices().exists(new
IndicesExistsRequest(index.toLowerCase(),
type.toLowerCase())).actionGet().isExists();

Third:
esClient.admin().indices().typesExists(new TypesExistsRequest(new String[]
{ index }, type)).actionGet().isExists();

But which is the best approach?

Best regards!
Alex

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Jörg Prante) #2

Preferable is client.admin().indices().typesExists(typesExistsRequest,
action) and checking for isExists() in the response.

See also
org.elasticsearch.rest.action.indices.exists.types.RestTypesExistsAction

Jörg

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #3