# Corrent mapping for a nesed multi\_field property?

**URL:** <https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433>\
**Category:** Elasticsearch\
**Created:** [June 15, 2013, 5:54pm UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433 "2013-06-15T17:54:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [June 15, 2013, 5:54pm UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/1 "2013-06-15T17:54:43Z")

</div>

I'm trying to return a single value if I search on a field that contains a  
list. Tags is my list and I have three values in it one, two and three.

tags : ["one", "two", "three"]

If I do a search for "two" I would like to only return the "two" in the  
value in the results.

I understand that a nested type is the way to go. The field "tag" is a  
multi field property as I'm analysing it in multiple ways. I having trouble  
getting a nested type working with a with a multi-field property. Here is  
the mapping of the tags at the moment:

{  
"document": {  
"properties": {  
"tags":{  
"type": "multi\_field",  
"fields":{  
"tags" {  
"type": "string",  
"index": "analyzed"  
},  
"untouched": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}

--  
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:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [June 16, 2013, 11:59am UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/2 "2013-06-16T11:59:07Z")

</div>

Hello,

If you only need the "two" returned (and only that), I guess you'll need  
parent-child relationships. Here are some references:

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

If you only need to highlight, the "two" there, you'd probably need  
highlighting:

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Sat, Jun 15, 2013 at 8:54 PM, es newbie [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> I'm trying to return a single value if I search on a field that contains a  
> list. Tags is my list and I have three values in it one, two and three.
> 
> tags : ["one", "two", "three"]
> 
> If I do a search for "two" I would like to only return the "two" in the  
> value in the results.
> 
> I understand that a nested type is the way to go. The field "tag" is a  
> multi field property as I'm analysing it in multiple ways. I having trouble  
> getting a nested type working with a with a multi-field property. Here is  
> the mapping of the tags at the moment:
> 
> {  
> "document": {  
> "properties": {  
> "tags":{  
> "type": "multi\_field",  
> "fields":{  
> "tags" {  
> "type": "string",  
> "index": "analyzed"  
> },  
> "untouched": {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> --  
> 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:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [June 16, 2013, 12:33pm UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/3 "2013-06-16T12:33:27Z")

</div>

Thanks I'll take a look at that.

On Sunday, June 16, 2013 12:59:07 PM UTC+1, Radu Gheorghe wrote:

> Hello,
> 
> If you only need the "two" returned (and only that), I guess you'll need  
> parent-child relationships. Here are some references:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/parent-field/)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query/)  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query/)
> 
> If you only need to highlight, the "two" there, you'd probably need  
> highlighting:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting/)
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Sat, Jun 15, 2013 at 8:54 PM, es newbie \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I'm trying to return a single value if I search on a field that contains  
> > a list. Tags is my list and I have three values in it one, two and three.
> > 
> > tags : ["one", "two", "three"]
> > 
> > If I do a search for "two" I would like to only return the "two" in the  
> > value in the results.
> > 
> > I understand that a nested type is the way to go. The field "tag" is a  
> > multi field property as I'm analysing it in multiple ways. I having trouble  
> > getting a nested type working with a with a multi-field property. Here is  
> > the mapping of the tags at the moment:
> > 
> > {  
> > "document": {  
> > "properties": {  
> > "tags":{  
> > "type": "multi\_field",  
> > "fields":{  
> > "tags" {  
> > "type": "string",  
> > "index": "analyzed"  
> > },  
> > "untouched": {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > --  
> > 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:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [June 16, 2013, 7:03pm UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/4 "2013-06-16T19:03:57Z")

</div>

Hi Radu,

I'm not sure the the child/parent mapping is the way to go.

The tags field is indexed in multiple ways, so I need to to be a  
multi\_valued field. I want to return all values in the tag array for some  
queries. For an autocomplete search I only want to return the value in the  
array that is a match, not all of the values in the array. I also don't  
want to have to index the document fields twice, once for the document and  
once for the tags. Can I not do what I want with a nested type?

On Sunday, June 16, 2013 1:33:27 PM UTC+1, es newbie wrote:

> Thanks I'll take a look at that.
> 
> On Sunday, June 16, 2013 12:59:07 PM UTC+1, Radu Gheorghe wrote:
> 
> > Hello,
> > 
> > If you only need the "two" returned (and only that), I guess you'll need  
> > parent-child relationships. Here are some references:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/parent-field/)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query/)  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query/)
> > 
> > If you only need to highlight, the "two" there, you'd probably need  
> > highlighting:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/highlighting/)
> > 
> > ## Best regards, Radu
> > 
> > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > 
> > On Sat, Jun 15, 2013 at 8:54 PM, es newbie [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > 
> > > I'm trying to return a single value if I search on a field that contains  
> > > a list. Tags is my list and I have three values in it one, two and three.
> > > 
> > > tags : ["one", "two", "three"]
> > > 
> > > If I do a search for "two" I would like to only return the "two" in the  
> > > value in the results.
> > > 
> > > I understand that a nested type is the way to go. The field "tag" is a  
> > > multi field property as I'm analysing it in multiple ways. I having trouble  
> > > getting a nested type working with a with a multi-field property. Here is  
> > > the mapping of the tags at the moment:
> > > 
> > > {  
> > > "document": {  
> > > "properties": {  
> > > "tags":{  
> > > "type": "multi\_field",  
> > > "fields":{  
> > > "tags" {  
> > > "type": "string",  
> > > "index": "analyzed"  
> > > },  
> > > "untouched": {  
> > > "type": "string",  
> > > "index": "not\_analyzed"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > --  
> > > 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:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [June 17, 2013, 6:29am UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/5 "2013-06-17T06:29:12Z")

</div>

Hello,

Ah, right. Parent-child doesn't seem like a good fit in this case.

I said highlighting earlier, but I don't think it works with nested  
documents. At least not at the time of this thread:  
[http://elasticsearch-users.115913.n3.nabble.com/Highlighting-on-nested-documents-if-include-in-parent-is-set-to-true-td4021717.html](http://elasticsearch-users.115913.n3.nabble.com/Highlighting-on-nested-documents-if-include-in-parent-is-set-to-true-td4021717.html)

So maybe you'll have to look at that array from your application.

On Sun, Jun 16, 2013 at 10:03 PM, es newbie [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Hi Radu,
> 
> I'm not sure the the child/parent mapping is the way to go.
> 
> The tags field is indexed in multiple ways, so I need to to be a  
> multi\_valued field. I want to return all values in the tag array for some  
> queries. For an autocomplete search I only want to return the value in the  
> array that is a match, not all of the values in the array. I also don't  
> want to have to index the document fields twice, once for the document and  
> once for the tags. Can I not do what I want with a nested type?
> 
> On Sunday, June 16, 2013 1:33:27 PM UTC+1, es newbie wrote:
> 
> > Thanks I'll take a look at that.
> > 
> > On Sunday, June 16, 2013 12:59:07 PM UTC+1, Radu Gheorghe wrote:
> > 
> > > Hello,
> > > 
> > > If you only need the "two" returned (and only that), I guess you'll need  
> > > parent-child relationships. Here are some references:  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/ **guide/reference/mapping/** parent-field/)[http://www.elasticsearch.org/guide/reference/mapping/parent-field/](http://www.elasticsearch.org/guide/reference/mapping/parent-field/)  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/query-dsl/has-)\*\*  
> > > child-query/[http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query/](http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query/)  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/query-dsl/has-)\*\*  
> > > parent-query/[http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query/](http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query/)
> > > 
> > > If you only need to highlight, the "two" there, you'd probably need  
> > > highlighting:  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/api/search/)\*\*  
> > > highlighting/[http://www.elasticsearch.org/guide/reference/api/search/highlighting/](http://www.elasticsearch.org/guide/reference/api/search/highlighting/)
> > > 
> > > ## Best regards, Radu
> > > 
> > > [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> > > 
> > > On Sat, Jun 15, 2013 at 8:54 PM, es newbie [dan.t...@gmail.com](mailto:dan.t...@gmail.com) wrote:
> > > 
> > > > I'm trying to return a single value if I search on a field that  
> > > > contains a list. Tags is my list and I have three values in it one, two and  
> > > > three.
> > > > 
> > > > tags : ["one", "two", "three"]
> > > > 
> > > > If I do a search for "two" I would like to only return the "two" in the  
> > > > value in the results.
> > > > 
> > > > I understand that a nested type is the way to go. The field "tag" is a  
> > > > multi field property as I'm analysing it in multiple ways. I having trouble  
> > > > getting a nested type working with a with a multi-field property. Here is  
> > > > the mapping of the tags at the moment:
> > > > 
> > > > {  
> > > > "document": {  
> > > > "properties": {  
> > > > "tags":{  
> > > > "type": "multi\_field",  
> > > > "fields":{  
> > > > "tags" {  
> > > > "type": "string",  
> > > > "index": "analyzed"  
> > > > },  
> > > > "untouched": {  
> > > > "type": "string",  
> > > > "index": "not\_analyzed"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > --  
> > > > 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.  
> > > > 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).

--  
[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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:30am UTC](https://discuss.elastic.co/t/corrent-mapping-for-a-nesed-multi-field-property/12433/6 "2017-07-06T02:30:53Z")

</div>


