Java API to get a mapping

I don't find any Java API to get a mapping for an index. Did I missed something or it is just not implemented yet ?

If just not implemented, I can try to take care of implementing it and provide a patch.

Nicolas

Yeah, I had a hard time finding it also. You need to fetch the ClusterState,
then get the IndexMetaData then you get your mapping from one of its
mappings() methods.

To get "myType" mapping from the "myIndex" index:

ClusterState cs =
client.admin().cluster().prepareState().setFilterIndices("myIndex").execute().actionGet().getState();
IndexMetaData imd = cs.getMetaData().index("myIndex")
MappingMetaData mdd = imd.mapping("myType")

Philippe

2011/5/26 Nicolas Lalevée nicolas.lalevee@hibnet.org

I don't find any Java API to get a mapping for an index. Did I missed
something or it is just not implemented yet ?

If just not implemented, I can try to take care of implementing it and
provide a patch.

Nicolas

Le 26 mai 2011 à 15:16, Philippe Laflamme a écrit :

Yeah, I had a hard time finding it also. You need to fetch the ClusterState, then get the IndexMetaData then you get your mapping from one of its mappings() methods.

To get "myType" mapping from the "myIndex" index:

ClusterState cs = client.admin().cluster().prepareState().setFilterIndices("myIndex").execute().actionGet().getState();
IndexMetaData imd = cs.getMetaData().index("myIndex")
MappingMetaData mdd = imd.mapping("myType")

ha great thanks !

Nicolas

Here is a sample of how it is done in the REST GET mapping endpoint: https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/mapping/get/RestGetMappingAction.java

On Thursday, May 26, 2011 at 4:22 PM, Nicolas Lalevée wrote:

Le 26 mai 2011 à 15:16, Philippe Laflamme a écrit :

Yeah, I had a hard time finding it also. You need to fetch the ClusterState, then get the IndexMetaData then you get your mapping from one of its mappings() methods.

To get "myType" mapping from the "myIndex" index:

ClusterState cs = client.admin().cluster().prepareState().setFilterIndices("myIndex").execute().actionGet().getState();
IndexMetaData imd = cs.getMetaData().index("myIndex")
MappingMetaData mdd = imd.mapping("myType")

ha great thanks !

Nicolas