# Read/access field mapping information

**URL:** <https://discuss.elastic.co/t/read-access-field-mapping-information/5998>\
**Category:** Elasticsearch\
**Created:** [November 28, 2011, 4:58pm UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998 "2011-11-28T16:58:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vannya](https://avatars.discourse-cdn.com/v4/letter/v/e495f1/32.png) [@vannya](https://discuss.elastic.co/u/vannya)\
**Post date:** [November 28, 2011, 4:58pm UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998/1 "2011-11-28T16:58:53Z")

</div>

Hi all,

In my river, I would like to access mapping information based in the  
fields.  
Example:  
Having this mapping:  
{  
"tweet" : {  
"properties" : {  
"message" : {"type" : "string", "store" : "yes",  
"enabled": false}  
}  
}  
}

I would like to do this...

ClusterState cs =  
client.admin().cluster().prepareState().setFilterIndices("my\_index").execute().actionGet().getState();  
IndexMetaData imd = cs.getMetaData().index("my\_index");  
MappingMetaData mdd = = imd.mapping("my\_type");

HashMap \<String, Object\> mapped\_node = mdd.getMapByPath("message");

... and then get the type, store and enabled as mapped\_node keys, with  
the corresponding value.

Is this possible?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 28, 2011, 6:04pm UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998/2 "2011-11-28T18:04:56Z")

</div>

You will need to parse it yourself from the compressed string that its  
stored internally, but I will add a method to return it as Map.

On Mon, Nov 28, 2011 at 6:58 PM, vannya [vannyas@gmail.com](mailto:vannyas@gmail.com) wrote:

> Hi all,
> 
> In my river, I would like to access mapping information based in the  
> fields.  
> Example:  
> Having this mapping:  
> {  
> "tweet" : {  
> "properties" : {  
> "message" : {"type" : "string", "store" : "yes",  
> "enabled": false}  
> }  
> }  
> }
> 
> I would like to do this...
> 
> ClusterState cs =
> 
> client.admin().cluster().prepareState().setFilterIndices("my\_index").execute().actionGet().getState();  
> IndexMetaData imd = cs.getMetaData().index("my\_index");  
> MappingMetaData mdd = = imd.mapping("my\_type");
> 
> HashMap \<String, Object\> mapped\_node = mdd.getMapByPath("message");
> 
> ... and then get the type, store and enabled as mapped\_node keys, with  
> the corresponding value.
> 
> Is this possible?

---

<div class="post-metadata">

**Author:** ![vannya](https://avatars.discourse-cdn.com/v4/letter/v/e495f1/32.png) [@vannya](https://discuss.elastic.co/u/vannya)\
**Post date:** [November 28, 2011, 6:18pm UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998/3 "2011-11-28T18:18:29Z")

</div>

Thanks Shay for the fast answer!  
We already parse the mapping ourselves, but it will be easier with a  
Map!

On Nov 28, 6:04 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You will need to parse it yourself from the compressed string that its  
> stored internally, but I will add a method to return it as Map.
> 
> On Mon, Nov 28, 2011 at 6:58 PM, vannya [vann...@gmail.com](mailto:vann...@gmail.com) wrote:
> 
> > Hi all,
> 
> > In my river, I would like to access mapping information based in the  
> > fields.  
> > Example:  
> > Having this mapping:  
> > {  
> > "tweet" : {  
> > "properties" : {  
> > "message" : {"type" : "string", "store" : "yes",  
> > "enabled": false}  
> > }  
> > }  
> > }
> 
> > I would like to do this...
> 
> > ClusterState cs =
> 
> > client.admin().cluster().prepareState().setFilterIndices("my\_index").execut e().actionGet().getState();  
> > IndexMetaData imd = cs.getMetaData().index("my\_index");  
> > MappingMetaData mdd = = imd.mapping("my\_type");
> 
> > HashMap \<String, Object\> mapped\_node = mdd.getMapByPath("message");
> 
> > ... and then get the type, store and enabled as mapped\_node keys, with  
> > the corresponding value.
> 
> > Is this possible?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 28, 2011, 6:22pm UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998/4 "2011-11-28T18:22:07Z")

</div>

Np, pushed it, it will be part of upcoming 0.18.5.

On Mon, Nov 28, 2011 at 8:18 PM, vannya [vannyas@gmail.com](mailto:vannyas@gmail.com) wrote:

> Thanks Shay for the fast answer!  
> We already parse the mapping ourselves, but it will be easier with a  
> Map!
> 
> On Nov 28, 6:04 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > You will need to parse it yourself from the compressed string that its  
> > stored internally, but I will add a method to return it as Map.
> > 
> > On Mon, Nov 28, 2011 at 6:58 PM, vannya [vann...@gmail.com](mailto:vann...@gmail.com) wrote:
> > 
> > > Hi all,
> > 
> > > In my river, I would like to access mapping information based in the  
> > > fields.  
> > > Example:  
> > > Having this mapping:  
> > > {  
> > > "tweet" : {  
> > > "properties" : {  
> > > "message" : {"type" : "string", "store" : "yes",  
> > > "enabled": false}  
> > > }  
> > > }  
> > > }
> > 
> > > I would like to do this...
> > 
> > > ClusterState cs =
> > 
> > >
> 
> client.admin().cluster().prepareState().setFilterIndices("my\_index").execut  
> e().actionGet().getState();
> 
> > > IndexMetaData imd = cs.getMetaData().index("my\_index");  
> > > MappingMetaData mdd = = imd.mapping("my\_type");
> > 
> > > HashMap \<String, Object\> mapped\_node = mdd.getMapByPath("message");
> > 
> > > ... and then get the type, store and enabled as mapped\_node keys, with  
> > > the corresponding value.
> > 
> > > Is this possible?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:47am UTC](https://discuss.elastic.co/t/read-access-field-mapping-information/5998/5 "2017-07-06T03:47:14Z")

</div>


