Java API to get a mapping

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Java API to get a mapping

Nicolas Lalevée
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

Reply | Threaded
Open this post in threaded view
|

Re: Java API to get a mapping

plaflamme
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 <[hidden email]>
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


Reply | Threaded
Open this post in threaded view
|

Re: Java API to get a mapping

Nicolas Lalevée

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

Reply | Threaded
Open this post in threaded view
|

Re: Java API to get a mapping

kimchy
Administrator

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