Indexing a document whith a multi_field mapping

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.
For more options, visit https://groups.google.com/groups/opt_out.

Hiya

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"
}
}
'

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.
For more options, visit https://groups.google.com/groups/opt_out.

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 -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 -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 -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.
For more options, visit https://groups.google.com/groups/opt_out.

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 -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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.