# Getting \_id field in elasticsearch to map to a field in HIVE

**URL:** <https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773>\
**Category:** Elasticsearch\
**Created:** [July 21, 2014, 8:10pm UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773 "2014-07-21T20:10:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiveesuser](https://avatars.discourse-cdn.com/v4/letter/h/5f8ce5/32.png) [@hiveesuser](https://discuss.elastic.co/u/hiveesuser)\
**Post date:** [July 21, 2014, 8:10pm UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773/1 "2014-07-21T20:10:19Z")

</div>

Hi,

I am working on a project to integrate hive and elasticsearch and for one  
of our use case we are loading data from ELASTISCSEARCH --\> HIVE.

During this process I want to store the \_id field which is in elasticsearch  
document in hive. I am able to get the fields which are part of \_source  
like messages, @timestamp etc but I am not able to get the \_id associated  
with that particular document.

The following is the sample table I am trying to create

create external table eshivetable (id string,eventdate timestamp, host  
string, username string, message string) STORED BY  
'org.elasticsearch.hadoop.hive.EsStorageHandler'  
TBLPROPERTIES('es.resource' = 'logstash-\*/syslog', 'es.mapping.names' =  
'id:\_id,eventdate:@timestamp,host:host,username:username,message:message','es.nodes'='10.10.10.50','es.port'='9200','es.query'='?q=type:syslog');

So when I select id it returns a null value...

Can some one help me with this please.

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5d2eb38d-9f0d-4329-ba2b-0d28c06f98e5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5d2eb38d-9f0d-4329-ba2b-0d28c06f98e5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![drudim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drudim/32/3533_2.png) [@drudim](https://discuss.elastic.co/u/drudim)\
**Post date:** [July 1, 2015, 10:24am UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773/2 "2015-07-01T10:24:03Z")

</div>

Have the same issue, does anyone know the solution?

---

<div class="post-metadata">

**Author:** ![drudim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drudim/32/3533_2.png) [@drudim](https://discuss.elastic.co/u/drudim)\
**Post date:** [July 1, 2015, 12:27pm UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773/3 "2015-07-01T12:27:26Z")

</div>

Found the solution:

```
create external table some_table (id string)
stored by 'org.elasticsearch.hadoop.hive.EsStorageHandler'
tblproperties (
    'es.resource' = '<index>/<type>',
    'es.nodes' = '<es_host>',
    'es.read.metadata' = 'true',
    'es.mapping.names' = 'id:_metadata._id'
);
```

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [June 7, 2017, 9:12am UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773/4 "2017-06-07T09:12:06Z")

</div>

What about:

> es.mapping.id

From [Configuration | Elasticsearch for Apache Hadoop [2.4] | Elastic](https://www.elastic.co/guide/en/elasticsearch/hadoop/2.4/configuration.html#cfg-mapping)

---

<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:** [November 4, 2022, 4:01am UTC](https://discuss.elastic.co/t/getting--id-field-in-elasticsearch-to-map-to-a-field-in-hive/18773/5 "2022-11-04T04:01:25Z")

</div>


