# Mapping for parent id to extract from the source

**URL:** https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988
**Category:** Elasticsearch
**Created:** [July 29, 2013, 4:59pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988 "2013-07-29T16:59:08Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 4:59pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/1 "2013-07-29T16:59:08Z")

</div>

I would like to know if it is possible to create a mapping for parent id to  
be extracted from the source, instead of specifying in the index request.

I could see that the \_id mapping is possible as below, similarly I looking  
for parent id mapping

{  
"tweet" : {  
"\_id" : {  
"path" : "post\_id"  
}  
}  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 5:44pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/2 "2013-07-29T17:44:58Z")

</div>

In otherwords

Can I use a "path" for the \_parent field?

On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:

> I would like to know if it is possible to create a mapping for parent id  
> to be extracted from the source, instead of specifying in the index request.
> 
> I could see that the \_id mapping is possible as below, similarly I looking  
> for parent id mapping
> 
> {  
> "tweet" : {  
> "\_id" : {  
> "path" : "post\_id"  
> }  
> }  
> }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 5:51pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/3 "2013-07-29T17:51:58Z")

</div>

By looking into the source code  
org.elasticsearch.index.mapper.internal.ParentFieldMapper, it is not  
possible.  
Can any one confirm?

On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:

> In otherwords
> 
> Can I use a "path" for the \_parent field?
> 
> On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> 
> > I would like to know if it is possible to create a mapping for parent id  
> > to be extracted from the source, instead of specifying in the index request.
> > 
> > I could see that the \_id mapping is possible as below, similarly I  
> > looking for parent id mapping
> > 
> > {  
> > "tweet" : {  
> > "\_id" : {  
> > "path" : "post\_id"  
> > }  
> > }  
> > }

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [July 29, 2013, 5:56pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/4 "2013-07-29T17:56:48Z")

</div>

I don't think it is possible, but since parent is basically an alias for  
setting the routing value you can probably use the \_routing field and  
related path setting along with the normal parent mapping.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Thanks,  
Matt Weber

On Mon, Jul 29, 2013 at 10:51 AM, Govind M [govindm@gmail.com](mailto:govindm@gmail.com) wrote:

> By looking into the source code  
> org.elasticsearch.index.mapper.internal.ParentFieldMapper, it is not  
> possible.  
> Can any one confirm?
> 
> On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:
> 
> > In otherwords
> > 
> > Can I use a "path" for the \_parent field?
> > 
> > On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> > 
> > > I would like to know if it is possible to create a mapping for parent id  
> > > to be extracted from the source, instead of specifying in the index request.
> > > 
> > > I could see that the \_id mapping is possible as below, similarly I  
> > > looking for parent id mapping
> > > 
> > > {  
> > > "tweet" : {  
> > > "\_id" : {  
> > > "path" : "post\_id"  
> > > }  
> > > }  
> > > }
> > > 
> > > --  
> > > 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).  
> > > 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 8:02pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/5 "2013-07-29T20:02:04Z")

</div>

Hello Matt,

Thanks for the reply.  
If I set the \_routing filed then the \_parent filed in the source is  
optional ?

-Govind

On Monday, July 29, 2013 10:56:48 AM UTC-7, Matt Weber wrote:

> I don't think it is possible, but since parent is basically an alias for  
> setting the routing value you can probably use the \_routing field and  
> related path setting along with the normal parent mapping.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/routing-field/)
> 
> Thanks,  
> Matt Weber
> 
> On Mon, Jul 29, 2013 at 10:51 AM, Govind M \<[gov...@gmail.com](mailto:gov...@gmail.com) \<javascript:\>
> 
> > wrote:
> 
> > By looking into the source code  
> > org.elasticsearch.index.mapper.internal.ParentFieldMapper, it is not  
> > possible.  
> > Can any one confirm?
> > 
> > On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:
> > 
> > > In otherwords
> > > 
> > > Can I use a "path" for the \_parent field?
> > > 
> > > On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> > > 
> > > > I would like to know if it is possible to create a mapping for parent  
> > > > id to be extracted from the source, instead of specifying in the index  
> > > > request.
> > > > 
> > > > I could see that the \_id mapping is possible as below, similarly I  
> > > > looking for parent id mapping
> > > > 
> > > > {  
> > > > "tweet" : {
> > > > 
> > > > ```
> > > > "_id" : {
> > > > 
> > > > "path" : "post_id"
> > > > 
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > > 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)
#### Post date: [July 29, 2013, 8:32pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/6 "2013-07-29T20:32:24Z")

</div>

Actually, now that I think about it this might since it won't set the  
\_parent field which I believe is used in the child id cache. I would need  
to double check in the source. At any rate, you should open an issue to  
support passing in the parent value via a field path during indexing.

Thanks,  
Matt Weber

On Mon, Jul 29, 2013 at 1:02 PM, Govind M [govindm@gmail.com](mailto:govindm@gmail.com) wrote:

> Hello Matt,
> 
> Thanks for the reply.  
> If I set the \_routing filed then the \_parent filed in the source is  
> optional ?
> 
> -Govind
> 
> On Monday, July 29, 2013 10:56:48 AM UTC-7, Matt Weber wrote:
> 
> > I don't think it is possible, but since parent is basically an alias for  
> > setting the routing value you can probably use the \_routing field and  
> > related path setting along with the normal parent mapping.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** routing-field/)[http://www.elasticsearch.org/guide/reference/mapping/routing-field/](http://www.elasticsearch.org/guide/reference/mapping/routing-field/)
> > 
> > Thanks,  
> > Matt Weber
> > 
> > On Mon, Jul 29, 2013 at 10:51 AM, Govind M [gov...@gmail.com](mailto:gov...@gmail.com) wrote:
> > 
> > > By looking into the source code org.elasticsearch.index.\*\*  
> > > mapper.internal.\*\*ParentFieldMapper, it is not possible.  
> > > Can any one confirm?
> > > 
> > > On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:
> > > 
> > > > In otherwords
> > > > 
> > > > Can I use a "path" for the \_parent field?
> > > > 
> > > > On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> > > > 
> > > > > I would like to know if it is possible to create a mapping for parent  
> > > > > id to be extracted from the source, instead of specifying in the index  
> > > > > request.
> > > > > 
> > > > > I could see that the \_id mapping is possible as below, similarly I  
> > > > > looking for parent id mapping
> > > > > 
> > > > > {  
> > > > > "tweet" : {
> > > > > 
> > > > > ```
> > > > > "_id" : {
> > > > > 
> > > > > "path" : "post_id"
> > > > > 
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }
> > > > > 
> > > > > --  
> > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[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).  
> > 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 8:53pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/7 "2013-07-29T20:53:23Z")

</div>

Thanks a lot Matt.

I will certainly open an ticket for this support. Please let me know if  
you find any other alternative.

On Monday, July 29, 2013 1:32:24 PM UTC-7, Matt Weber wrote:

> Actually, now that I think about it this might since it won't set the  
> \_parent field which I believe is used in the child id cache. I would need  
> to double check in the source. At any rate, you should open an issue to  
> support passing in the parent value via a field path during indexing.
> 
> Thanks,  
> Matt Weber
> 
> On Mon, Jul 29, 2013 at 1:02 PM, Govind M \<[gov...@gmail.com](mailto:gov...@gmail.com) \<javascript:\>\>wrote:
> 
> > Hello Matt,
> > 
> > Thanks for the reply.  
> > If I set the \_routing filed then the \_parent filed in the source is  
> > optional ?
> > 
> > -Govind
> > 
> > On Monday, July 29, 2013 10:56:48 AM UTC-7, Matt Weber wrote:
> > 
> > > I don't think it is possible, but since parent is basically an alias for  
> > > setting the routing value you can probably use the \_routing field and  
> > > related path setting along with the normal parent mapping.
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** routing-field/)[http://www.elasticsearch.org/guide/reference/mapping/routing-field/](http://www.elasticsearch.org/guide/reference/mapping/routing-field/)
> > > 
> > > Thanks,  
> > > Matt Weber
> > > 
> > > On Mon, Jul 29, 2013 at 10:51 AM, Govind M [gov...@gmail.com](mailto:gov...@gmail.com) wrote:
> > > 
> > > > By looking into the source code org.elasticsearch.index.\*\*  
> > > > mapper.internal.\*\*ParentFieldMapper, it is not possible.  
> > > > Can any one confirm?
> > > > 
> > > > On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:
> > > > 
> > > > > In otherwords
> > > > > 
> > > > > Can I use a "path" for the \_parent field?
> > > > > 
> > > > > On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> > > > > 
> > > > > > I would like to know if it is possible to create a mapping for parent  
> > > > > > id to be extracted from the source, instead of specifying in the index  
> > > > > > request.
> > > > > > 
> > > > > > I could see that the \_id mapping is possible as below, similarly I  
> > > > > > looking for parent id mapping
> > > > > > 
> > > > > > {  
> > > > > > "tweet" : {
> > > > > > 
> > > > > > ```
> > > > > > "_id" : {
> > > > > > 
> > > > > > "path" : "post_id"
> > > > > > 
> > > > > > }
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > --  
> > > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > 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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![govind](https://avatars.discourse-cdn.com/v4/letter/g/ac91a4/32.png) [@govind](https://discuss.elastic.co/u/govind)
#### Post date: [July 29, 2013, 9:01pm UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/8 "2013-07-29T21:01:19Z")

</div>

Matt,

Created issue [Feature to support passing in the parent value via a field path during indexing, same as \_id & \_routing. · Issue #3405 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3405)  
for this feature request.

-Govind

On Monday, July 29, 2013 1:53:23 PM UTC-7, Govind M wrote:

> Thanks a lot Matt.
> 
> I will certainly open an ticket for this support. Please let me know if  
> you find any other alternative.
> 
> On Monday, July 29, 2013 1:32:24 PM UTC-7, Matt Weber wrote:
> 
> > Actually, now that I think about it this might since it won't set the  
> > \_parent field which I believe is used in the child id cache. I would need  
> > to double check in the source. At any rate, you should open an issue to  
> > support passing in the parent value via a field path during indexing.
> > 
> > Thanks,  
> > Matt Weber
> > 
> > On Mon, Jul 29, 2013 at 1:02 PM, Govind M [gov...@gmail.com](mailto:gov...@gmail.com) wrote:
> > 
> > > Hello Matt,
> > > 
> > > Thanks for the reply.  
> > > If I set the \_routing filed then the \_parent filed in the source is  
> > > optional ?
> > > 
> > > -Govind
> > > 
> > > On Monday, July 29, 2013 10:56:48 AM UTC-7, Matt Weber wrote:
> > > 
> > > > I don't think it is possible, but since parent is basically an alias  
> > > > for setting the routing value you can probably use the \_routing field and  
> > > > related path setting along with the normal parent mapping.
> > > > 
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** routing-field/)[http://www.elasticsearch.org/guide/reference/mapping/routing-field/](http://www.elasticsearch.org/guide/reference/mapping/routing-field/)
> > > > 
> > > > Thanks,  
> > > > Matt Weber
> > > > 
> > > > On Mon, Jul 29, 2013 at 10:51 AM, Govind M [gov...@gmail.com](mailto:gov...@gmail.com) wrote:
> > > > 
> > > > > By looking into the source code org.elasticsearch.index.\*\*  
> > > > > mapper.internal.\*\*ParentFieldMapper, it is not possible.  
> > > > > Can any one confirm?
> > > > > 
> > > > > On Monday, July 29, 2013 10:44:58 AM UTC-7, Govind M wrote:
> > > > > 
> > > > > > In otherwords
> > > > > > 
> > > > > > Can I use a "path" for the \_parent field?
> > > > > > 
> > > > > > On Monday, July 29, 2013 9:59:08 AM UTC-7, Govind M wrote:
> > > > > > 
> > > > > > > I would like to know if it is possible to create a mapping for  
> > > > > > > parent id to be extracted from the source, instead of specifying in the  
> > > > > > > index request.
> > > > > > > 
> > > > > > > I could see that the \_id mapping is possible as below, similarly I  
> > > > > > > looking for parent id mapping
> > > > > > > 
> > > > > > > {  
> > > > > > > "tweet" : {
> > > > > > > 
> > > > > > > ```
> > > > > > > "_id" : {
> > > > > > > 
> > > > > > > "path" : "post_id"
> > > > > > > 
> > > > > > > }
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }
> > > > > > > 
> > > > > > > --  
> > > > > > > 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 elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > > > 
> > > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.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).  
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, 2:23am UTC](https://discuss.elastic.co/t/mapping-for-parent-id-to-extract-from-the-source/12988/9 "2017-07-06T02:23:55Z")

</div>


