# Using a combined field as id mapping in ElasticSearch

**URL:** <https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281>\
**Category:** Elasticsearch\
**Created:** [January 16, 2014, 7:52pm UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281 "2014-01-16T19:52:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [January 16, 2014, 7:52pm UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281/1 "2014-01-16T19:52:26Z")

</div>

I'm using ES 0.90.7.

Is there a way to do \_id mapped to a custom value which is based on more than one field?

> <https://stackoverflow.com/questions/21041952/using-a-combined-field-as-id-mapping-in-elasticsearch>

Like i want \_id to combine srId and closeDt as our document key?

this one doesnt work.

{  
"mappings": {  
"json": {  
"\_id": {  
"path": "srId.closeDt",  
"properties": {  
"srId": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"closeDt": {  
"index": "not\_analyzed",  
"type": "long"  
}  
}  
}  
}  
}  
}'

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 16, 2014, 9:14pm UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281/2 "2014-01-16T21:14:05Z")

</div>

You should do that on a client level and add a new attribute in your doc or send the right \_id.

My 2 cents.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 janv. 2014 à 20:52, vinamar [vinamar@gmail.com](mailto:vinamar@gmail.com) a écrit :

> I'm using ES 0.90.7.
> 
> Is there a way to do \_id mapped to a custom value which is based on more  
> than one field?  
> [Using a combined field as id mapping in ElasticSearch - Stack Overflow](http://stackoverflow.com/questions/21041952/using-a-combined-field-as-id-mapping-in-elasticsearch)
> 
> Like i want \_id to combine srId and closeDt as our document key?
> 
> this one doesnt work.
> 
> {  
> "mappings": {  
> "json": {  
> "\_id": {  
> "path": "srId.closeDt",  
> "properties": {  
> "srId": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "closeDt": {  
> "index": "not\_analyzed",  
> "type": "long"  
> }  
> }  
> }  
> }  
> }  
> }'
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Using-a-combined-field-as-id-mapping-in-ElasticSearch-tp4047728.html](http://elasticsearch-users.115913.n3.nabble.com/Using-a-combined-field-as-id-mapping-in-ElasticSearch-tp4047728.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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/1389901947442-4047728.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1389901947442-4047728.post%40n3.nabble.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/22CD0FFA-DDF2-4D73-B96A-6AD75CA15CCF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/22CD0FFA-DDF2-4D73-B96A-6AD75CA15CCF%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [January 16, 2014, 10:56pm UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281/3 "2014-01-16T22:56:18Z")

</div>

Hi David,

I'm using fsriver plugin. Is there a way to specify a script to generate a field like how couchDB river plugin is able to do.

> <https://stackoverflow.com/questions/15421720/how-do-i-index-all-the-revisions-of-a-couchdb-doc-using-elasticsearch-river-plug>

{  
"couchdoc" : {  
"\_id" : {  
"path" : "doc\_rev\_id"  
}  
}  
}  
{  
"type" : "couchdb",  
"couchdb" : {  
"script" : "ctx.doc.doc\_rev\_id = ctx.doc._id + '_' + ctx.doc.\_rev"  
}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2014, 6:07am UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281/4 "2014-01-17T06:07:40Z")

</div>

No. Scripts are not supported in fsriver. What do you want to add with scripts?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 janv. 2014 à 23:56, vinamar [vinamar@gmail.com](mailto:vinamar@gmail.com) a écrit :

> Hi David,
> 
> I'm using fsriver plugin. Is there a way to specify a script to generate a  
> field like how couchDB river plugin is able to do.
> 
> [How do I index all the revisions of a couchdb doc using elasticsearch river plugin - Stack Overflow](http://stackoverflow.com/questions/15421720/how-do-i-index-all-the-revisions-of-a-couchdb-doc-using-elasticsearch-river-plug)
> 
> {  
> "couchdoc" : {  
> "\_id" : {  
> "path" : "doc\_rev\_id"  
> }  
> }  
> }  
> {  
> "type" : "couchdb",  
> "couchdb" : {  
> "script" : "ctx.doc.doc\_rev\_id = ctx.doc._id + '_' + ctx.doc.\_rev"  
> }  
> }
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Using-a-combined-field-as-id-mapping-in-ElasticSearch-tp4047728p4047738.html](http://elasticsearch-users.115913.n3.nabble.com/Using-a-combined-field-as-id-mapping-in-ElasticSearch-tp4047728p4047738.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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/1389912978917-4047738.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1389912978917-4047738.post%40n3.nabble.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/68BBAFDD-7AD7-47CD-BB9F-1B77886EC10F%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/68BBAFDD-7AD7-47CD-BB9F-1B77886EC10F%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:56am UTC](https://discuss.elastic.co/t/using-a-combined-field-as-id-mapping-in-elasticsearch/15281/5 "2017-07-06T01:56:16Z")

</div>


