# Multi-valued field with properties issue

**URL:** <https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343>\
**Category:** Elasticsearch\
**Created:** [August 27, 2013, 11:36am UTC](https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343 "2013-08-27T11:36:46Z")\
**Posts on this page:** 4\
**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:** [August 27, 2013, 11:36am UTC](https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343/1 "2013-08-27T11:36:46Z")

</div>

Is it possible to have a mapping for a field that is both multi-valued and  
has properties? If I have a title field and I want to support both language  
specific and non-language specific versions of the field

{  
"book" :{  
"title": {  
"type":"multi\_field",  
"fields":{  
"title":{  
"type": "string",  
"index": "analyzed"  
},  
"untouched":{  
"type": "string",  
"index": "not\_analyzed",  
}  
}  
"properties":{  
"en":{  
"type": "multi\_field",  
"fields": {  
"en": {  
"type": "string",  
"index": "analyzed"  
},  
"untouched": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}

I want be able to index both documents below with the above mapping.

This works OK.

{  
"book":{  
"description": "Enterprise Search"  
}  
}

This fails with {"error":"MapperParsingException[failed to parse  
[description]]; nested: Elastic  
SearchIllegalArgumentException[unknown property [en]]; ","status":400}

{  
"book":{  
"description": {  
"en":"Enterprise Search"  
}  
}  
}

--  
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:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 27, 2013, 6:00pm UTC](https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343/2 "2013-08-27T18:00:09Z")

</div>

I have not looked at the mapping, but judging from your examples, it seems  
like you want book.description to be both a string or an object type. I  
would rethink your data model since the current structure is confusing not  
only during indexing (is it a string or an object?) but also during  
searching. What is the output for a search on the book.description field if  
it is an object?

You can have various multi fields on the same field (normal, untouched, en)  
or have another field parallel to description, such as description\_en.  
Multilingual is tough!

Cheers,

Ivan

--  
Ivan

On Tue, Aug 27, 2013 at 4:36 AM, dan [dan.tuffery@gmail.com](mailto:dan.tuffery@gmail.com) wrote:

> Is it possible to have a mapping for a field that is both multi-valued and  
> has properties? If I have a title field and I want to support both language  
> specific and non-language specific versions of the field
> 
> {  
> "book" :{  
> "title": {  
> "type":"multi\_field",  
> "fields":{  
> "title":{  
> "type": "string",  
> "index": "analyzed"  
> },  
> "untouched":{  
> "type": "string",  
> "index": "not\_analyzed",  
> }  
> }  
> "properties":{  
> "en":{  
> "type": "multi\_field",  
> "fields": {  
> "en": {  
> "type": "string",  
> "index": "analyzed"  
> },  
> "untouched": {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }  
> }  
> }
> 
> I want be able to index both documents below with the above mapping.
> 
> This works OK.
> 
> {  
> "book":{  
> "description": "Enterprise Search"  
> }  
> }
> 
> This fails with {"error":"MapperParsingException[failed to parse  
> [description]]; nested: Elastic  
> SearchIllegalArgumentException[unknown property [en]]; ","status":400}
> 
> {  
> "book":{  
> "description": {  
> "en":"Enterprise Search"  
> }  
> }  
> }
> 
> --  
> 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:** [August 28, 2013, 6:20am UTC](https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343/3 "2013-08-28T06:20:15Z")

</div>

Hi Ivan, thanks for your response.

--What is the output for a search on the book.description field if it is an  
object?

I have some logic that will map it to a string or object depending what is  
returned in the results.

Searching with this mapping shouldn't be an issue. if I want to search on  
the string version of description I can just use 'description', if the user  
has provided a language, say 'en', i can search on 'description.en'.

The only problem I am facing is indexing a language sensitive field with my  
mapping.

On Tuesday, August 27, 2013 7:00:09 PM UTC+1, Ivan Brusic wrote:

> I have not looked at the mapping, but judging from your examples, it seems  
> like you want book.description to be both a string or an object type. I  
> would rethink your data model since the current structure is confusing not  
> only during indexing (is it a string or an object?) but also during  
> searching. What is the output for a search on the book.description field if  
> it is an object?
> 
> You can have various multi fields on the same field (normal, untouched,  
> en) or have another field parallel to description, such as description\_en.  
> Multilingual is tough!
> 
> Cheers,
> 
> Ivan
> 
> --  
> Ivan
> 
> On Tue, Aug 27, 2013 at 4:36 AM, dan \<[dan.t...@gmail.com](mailto:dan.t...@gmail.com) \<javascript:\>\>wrote:
> 
> > Is it possible to have a mapping for a field that is both multi-valued  
> > and has properties? If I have a title field and I want to support both  
> > language specific and non-language specific versions of the field
> > 
> > {  
> > "book" :{  
> > "title": {  
> > "type":"multi\_field",  
> > "fields":{  
> > "title":{  
> > "type": "string",  
> > "index": "analyzed"  
> > },  
> > "untouched":{  
> > "type": "string",  
> > "index": "not\_analyzed",  
> > }  
> > }  
> > "properties":{  
> > "en":{  
> > "type": "multi\_field",  
> > "fields": {  
> > "en": {  
> > "type": "string",  
> > "index": "analyzed"  
> > },  
> > "untouched": {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > I want be able to index both documents below with the above mapping.
> > 
> > This works OK.
> > 
> > {  
> > "book":{  
> > "description": "Enterprise Search"  
> > }  
> > }
> > 
> > This fails with {"error":"MapperParsingException[failed to parse  
> > [description]]; nested: Elastic  
> > SearchIllegalArgumentException[unknown property [en]]; ","status":400}
> > 
> > {  
> > "book":{  
> > "description": {  
> > "en":"Enterprise Search"  
> > }  
> > }  
> > }
> > 
> > --  
> > 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:** ![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:19am UTC](https://discuss.elastic.co/t/multi-valued-field-with-properties-issue/13343/4 "2017-07-06T02:19:23Z")

</div>


