# Indexing a document whith a multi\_field mapping

**URL:** <https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589>\
**Category:** Elasticsearch\
**Created:** [February 1, 2013, 1:21pm UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589 "2013-02-01T13:21:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pierre\_De\_Soyres](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pierre\_De\_Soyres](https://discuss.elastic.co/u/Pierre_De_Soyres)\
**Post date:** [February 1, 2013, 1:21pm UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589/1 "2013-02-01T13:21:55Z")

</div>

Hi,

I'm trying to index a document on multi\_field mapping :

here is my mapping :

curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
{  
"test": {  
"properties": {  
"field": {  
"type": "multi\_field",  
"fields": {  
"fr\_FR": {  
"type": "string"  
},  
"es\_ES": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
'

and then, when i add a document using :  
curl -XPUT [http://localhost:9200/test/test/1](http://localhost:9200/test/test/1) -d '  
{  
"field": {  
"fr\_FR": "phrase en francais",  
"es\_ES": "palabra en espanol"  
}  
}  
'

I'm getting this error in elasticsearch logs :

[2013-02-01 14:19:38,998][DEBUG][action.index] [Ani-Mator]  
[test][2], node[s--AZ\_0PRxOpVlzdG8TIlQ], [P], s[STARTED]: Failed to execute  
[index {[test][test][1], source[{"field":{"fr\_FR":"phrase en  
francais","es\_ES":"palabra en espanol"}}]}]  
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
[field.es\_ES]  
at  
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)  
at  
org.elasticsearch.index.mapper.multifield.MultiFieldMapper.parse(MultiFieldMapper.java:211)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:507)  
at  
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:449)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:318)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:531)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:429)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:662)  
Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException: unknown  
property [fr\_FR]  
at  
org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:276)  
at  
org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:46)  
at  
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)  
... 12 more

What is wrong ?

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 1, 2013, 1:38pm UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589/2 "2013-02-01T13:38:18Z")

</div>

Hiya

> I'm trying to index a document on multi\_field mapping :
> 
> here is my mapping :
> 
> curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
> {  
> "test": {  
> "properties": {  
> "field": {  
> "type": "multi\_field",  
> "fields": {  
> "fr\_FR": {  
> "type": "string"  
> },  
> "es\_ES": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> '
> 
> and then, when i add a document using :
> 
> curl -XPUT [http://localhost:9200/test/test/1](http://localhost:9200/test/test/1) -d '
> 
> {  
> "field": {  
> "fr\_FR": "phrase en francais",  
> "es\_ES": "palabra en espanol"  
> }  
> }  
> '

You have misunderstood the use of multi\_fields. What you are indexing  
is an "object", not a multi-field, which you would index as:

{ "field": "A phrase in some language" }

You could then QUERY the sub-fields, eg "field.fr\_FR"

Also, you should have a "main" sub-field, called the same name as the  
field itself (in your example "field")

This would be queryable as "field" or as "field.field"

clint

--  
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:** ![Pierre\_De\_Soyres](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Pierre\_De\_Soyres](https://discuss.elastic.co/u/Pierre_De_Soyres)\
**Post date:** [February 1, 2013, 1:54pm UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589/3 "2013-02-01T13:54:29Z")

</div>

Thank you for response,

my need is to have a document which has some muli-localized fields. In my  
example "field" has two traductions of itself in two different languages.

After reading from you, I think I should use "object" mapping type :

curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
{  
"test": {  
"properties": {  
"field": {  
"type": "object",  
"properties": {  
"fr\_FR": {  
"type": "string"  
},  
"es\_ES": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
'

Can I have a different analyzer for fr\_FR and es\_ES ? In other words, can I  
use following mapping :  
curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
{  
"test": {  
"properties": {  
"field": {  
"type": "object",  
"properties": {  
"fr\_FR": {  
"type": "string",  
"analyzer": "french"  
},  
"es\_ES": {  
"type": "string",  
"analyzer": "spanish"  
}  
}  
}  
}  
}  
}  
'

Pierre.

Le vendredi 1 février 2013 14:21:55 UTC+1, Pierre De Soyres a écrit :

> Hi,
> 
> I'm trying to index a document on multi\_field mapping :
> 
> here is my mapping :
> 
> curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
> {  
> "test": {  
> "properties": {  
> "field": {  
> "type": "multi\_field",  
> "fields": {  
> "fr\_FR": {  
> "type": "string"  
> },  
> "es\_ES": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }  
> '
> 
> and then, when i add a document using :  
> curl -XPUT [http://localhost:9200/test/test/1](http://localhost:9200/test/test/1) -d '  
> {  
> "field": {  
> "fr\_FR": "phrase en francais",  
> "es\_ES": "palabra en espanol"  
> }  
> }  
> '
> 
> I'm getting this error in elasticsearch logs :
> 
> [2013-02-01 14:19:38,998][DEBUG][action.index] [Ani-Mator]  
> [test][2], node[s--AZ\_0PRxOpVlzdG8TIlQ], [P], s[STARTED]: Failed to execute  
> [index {[test][test][1], source[{"field":{"fr\_FR":"phrase en  
> francais","es\_ES":"palabra en espanol"}}]}]  
> org.elasticsearch.index.mapper.MapperParsingException: Failed to parse  
> [field.es\_ES]  
> at  
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)  
> at  
> org.elasticsearch.index.mapper.multifield.MultiFieldMapper.parse(MultiFieldMapper.java:211)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:507)  
> at  
> org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:449)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:318)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:531)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:429)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)  
> at java.lang.Thread.run(Thread.java:662)  
> Caused by: org.elasticsearch.ElasticSearchIllegalArgumentException:  
> unknown property [fr\_FR]  
> at  
> org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:276)  
> at  
> org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:46)  
> at  
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)  
> ... 12 more
> 
> What is wrong ?

--  
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:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [February 1, 2013, 1:58pm UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589/4 "2013-02-01T13:58:19Z")

</div>

> Can I have a different analyzer for fr\_FR and es\_ES ? In other words,  
> can I use following mapping :  
> curl -XPUT [http://localhost:9200/test/test/\_mapping](http://localhost:9200/test/test/_mapping) -d '  
> {  
> "test": {  
> "properties": {  
> "field": {  
> "type": "object",  
> "properties": {  
> "fr\_FR": {  
> "type": "string",  
> "analyzer": "french"  
> },  
> "es\_ES": {  
> "type": "string",  
> "analyzer": "spanish"  
> }  
> }  
> }  
> }  
> }  
> }  
> '

yes, that looks fine

clint

> Pierre.
> 
> Le vendredi 1 février 2013 14:21:55 UTC+1, Pierre De Soyres a écrit :  
> Hi,
> 
> ```
> I'm trying to index a document on multi_field mapping :
>     
>     
> here is my mapping :
>     
>     
> curl -XPUT http://localhost:9200/test/test/_mapping -d '
> {
> "test": {
> "properties": {
> "field": {
> "type": "multi_field",
> "fields": {
> "fr_FR": {
> "type": "string"
> },
> "es_ES": {
> "type": "string"
> }
> }
> }
> }
> }
> }
> '
>     
>     
> and then, when i add a document using :
>     
> curl -XPUT http://localhost:9200/test/test/1 -d '
>     
> {
> "field": {
> "fr_FR": "phrase en francais",
> "es_ES": "palabra en espanol"
> }
> }
> '
>     
>     
> I'm getting this error in elasticsearch logs :
>     
>     
> [2013-02-01 14:19:38,998][DEBUG][action.index]
> [Ani-Mator] [test][2], node[s--AZ_0PRxOpVlzdG8TIlQ], [P],
> s[STARTED]: Failed to execute [index {[test][test][1],
> source[{"field":{"fr_FR":"phrase en francais","es_ES":"palabra
> en espanol"}}]}]
> org.elasticsearch.index.mapper.MapperParsingException: Failed
> to parse [field.es_ES]
> at
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:320)
> at
> org.elasticsearch.index.mapper.multifield.MultiFieldMapper.parse(MultiFieldMapper.java:211)
> at
> org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:507)
> at
> org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:449)
> at
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:486)
> at
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:430)
> at
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:318)
> at
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)
> at
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:531)
> at
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:429)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.runTask(ThreadPoolExecutor.java:886)
> at java.util.concurrent.ThreadPoolExecutor
> $Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
> Caused by:
> org.elasticsearch.ElasticSearchIllegalArgumentException:
> unknown property [fr_FR]
> at
> org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:276)
> at
> org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:46)
> at
> org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:307)
> ... 12 more
>     
>     
>     
>     
> What is wrong ?
> 
> ```
> 
> --  
> 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:** ![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:53am UTC](https://discuss.elastic.co/t/indexing-a-document-whith-a-multi-field-mapping/10589/5 "2017-07-06T02:53:34Z")

</div>


