# Combined document id combined form several fields?

**URL:** <https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753>\
**Category:** Elasticsearch\
**Created:** [November 18, 2012, 6:38pm UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753 "2012-11-18T18:38:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 18, 2012, 6:38pm UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/1 "2012-11-18T18:38:53Z")

</div>

Hi,

I've read [http://www.elasticsearch.org/guide/reference/mapping/id-field.html](http://www.elasticsearch.org/guide/reference/mapping/id-field.html) and  
have a followup question:

Is that possible to construct document id from several fields? For example,  
user's First and Last names?

I've tried something like  
{  
"\_id" : {  
"path" : ["first\_name", "last\_name"]  
}  
}  
}

But it falls back to default auto ID.

--

---

<div class="post-metadata">

**Author:** ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)\
**Post date:** [November 18, 2012, 6:45pm UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/2 "2012-11-18T18:45:55Z")

</div>

Create a field, unstored and not indexed, with the value you want, and set  
the path to it

On Sun, Nov 18, 2012 at 8:38 PM, Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com) wrote:

> Hi,
> 
> I've read  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html) and  
> have a followup question:
> 
> Is that possible to construct document id from several fields? For  
> example, user's First and Last names?
> 
> I've tried something like  
> {  
> "\_id" : {  
> "path" : ["first\_name", "last\_name"]  
> }  
> }  
> }
> 
> But it falls back to default auto ID.
> 
> --

--

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 18, 2012, 7:56pm UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/3 "2012-11-18T19:56:51Z")

</div>

Yeah, that's an easy cheat 🙂  
But I do not want another field.

May be there is a way to apply a script to generate an ID?

On 18 בנוב 2012, at 20:45, Itamar Syn-Hershko [itamar@code972.com](mailto:itamar@code972.com) wrote:

Create a field, unstored and not indexed, with the value you want, and set  
the path to it

On Sun, Nov 18, 2012 at 8:38 PM, Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com) wrote:

> Hi,
> 
> I've read  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html) and  
> have a followup question:
> 
> Is that possible to construct document id from several fields? For  
> example, user's First and Last names?
> 
> I've tried something like  
> {  
> "\_id" : {  
> "path" : ["first\_name", "last\_name"]  
> }  
> }  
> }
> 
> But it falls back to default auto ID.
> 
> --

--

--

---

<div class="post-metadata">

**Author:** ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)\
**Post date:** [November 18, 2012, 8:53pm UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/4 "2012-11-18T20:53:41Z")

</div>

Why do you care about another field if it isn't indexed?

On Sun, Nov 18, 2012 at 9:56 PM, Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com) wrote:

> Yeah, that's an easy cheat 🙂  
> But I do not want another field.
> 
> May be there is a way to apply a script to generate an ID?
> 
> On 18 בנוב 2012, at 20:45, Itamar Syn-Hershko [itamar@code972.com](mailto:itamar@code972.com) wrote:
> 
> Create a field, unstored and not indexed, with the value you want, and set  
> the path to it
> 
> On Sun, Nov 18, 2012 at 8:38 PM, Zaar Hai [haizaar@gmail.com](mailto:haizaar@gmail.com) wrote:
> 
> > Hi,
> > 
> > I've read  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html) and  
> > have a followup question:
> > 
> > Is that possible to construct document id from several fields? For  
> > example, user's First and Last names?
> > 
> > I've tried something like  
> > {  
> > "\_id" : {  
> > "path" : ["first\_name", "last\_name"]  
> > }  
> > }  
> > }
> > 
> > But it falls back to default auto ID.
> > 
> > --
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![haizaar](https://avatars.discourse-cdn.com/v4/letter/h/3d9bf3/32.png) [@haizaar](https://discuss.elastic.co/u/haizaar)\
**Post date:** [November 19, 2012, 8:52am UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/5 "2012-11-19T08:52:53Z")

</div>

I don't like keeping redundant information around, especially when I'm going  
to have 100m+ documents.  
If I'm gong to generate ID myself, then I better supply it directly as document  
ID while indexing it, instead of keeping as a field.

Zaar

On Sunday, November 18, 2012 10:53:46 PM UTC+2, Itamar Syn-Hershko wrote:

> Why do you care about another field if it isn't indexed?
> 
> On Sun, Nov 18, 2012 at 9:56 PM, Zaar Hai \<[hai...@gmail.com](mailto:hai...@gmail.com) \<javascript:\>\>wrote:
> 
> > Yeah, that's an easy cheat 🙂  
> > But I do not want another field.
> > 
> > May be there is a way to apply a script to generate an ID?
> > 
> > On 18 בנוב 2012, at 20:45, Itamar Syn-Hershko \<[ita...@code972.com](mailto:ita...@code972.com)\<javascript:\>\>  
> > wrote:
> > 
> > Create a field, unstored and not indexed, with the value you want, and  
> > set the path to it
> > 
> > On Sun, Nov 18, 2012 at 8:38 PM, Zaar Hai \<[hai...@gmail.com](mailto:hai...@gmail.com) \<javascript:\>
> > 
> > > wrote:
> > 
> > > Hi,
> > > 
> > > I've read  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/id-field.html) and  
> > > have a followup question:
> > > 
> > > Is that possible to construct document id from several fields? For  
> > > example, user's First and Last names?
> > > 
> > > I've tried something like  
> > > {  
> > > "\_id" : {  
> > > "path" : ["first\_name", "last\_name"]  
> > > }  
> > > }  
> > > }
> > > 
> > > But it falls back to default auto ID.
> > > 
> > > --
> > 
> > --
> > 
> > --

--

---

<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:03am UTC](https://discuss.elastic.co/t/combined-document-id-combined-form-several-fields/9753/6 "2017-07-06T03:03:45Z")

</div>


