Completion mapping type throws a misleading error on null value

I'm implementing an autocomplete feature using the new(ish) completion
type. We are implementing it against a series of fields, and in some
cases one of the fields is null. When the field is null, the completion
mapping parser throws an error but it refers to the next field in the
document, not the field with the completion type.

I created a simple Gist to demonstrate the problem.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e42cb0c9-d97e-4448-8257-5512865cc42f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

bash repro.sh

{"acknowledged":true}[2014-05-18 13:40:24,150][INFO ][cluster.metadata
] [Aelfyre Whitemane] [completion_type_cant_handle_the_null_truth]
creating index, cause [api], shards [1]/[0], mappings
{"acknowledged":true}[2014-05-18 13:40:24,224][INFO ][cluster.metadata
] [Aelfyre Whitemane] [completion_type_cant_handle_the_null_truth]
create_mapping [object]
{"acknowledged":true}[2014-05-18 13:40:24,245][INFO ][cluster.metadata
] [Aelfyre Whitemane] [completion_type_cant_handle_the_null_truth]
update_mapping [object] (dynamic)
{"_index":"completion_type_cant_handle_the_null_truth","_type":"object","_id":"1","_version":1,"created":true}[2014-05-18
13:40:24,265][DEBUG][action.index ] [Aelfyre Whitemane]
[completion_type_cant_handle_the_null_truth][0],
node[k4lbsgzYSlWzynQkVGqMaw], [P], s[STARTED]: Failed to execute [index
{[completion_type_cant_handle_the_null_truth][object][2], source[{"field1"
: null,"field2" : "nulls make me sad"}]}]
org.elasticsearch.index.mapper.MapperParsingException: failed to parse
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:540)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:462)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:384)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:556)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:426)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException: Unknown
field name[field2], must be one of [payload, input, weight, output]
at
org.elasticsearch.index.mapper.core.CompletionFieldMapper.parse(CompletionFieldMapper.java:237)
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeNullValue(ObjectMapper.java:505)
at
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:465)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:515)
... 8 more
{"error":"MapperParsingException[failed to parse]; nested:
ElasticsearchIllegalArgumentException[Unknown field name[field2], must be
one of [payload, input, weight, output]];
","status":400}MacBook-Boss:completionmapping glade$

On Sunday, May 18, 2014 1:40:06 PM UTC-7, Glade Luco wrote:

I'm implementing an autocomplete feature using the new(ish) completion
type. We are implementing it against a series of fields, and in some
cases one of the fields is null. When the field is null, the completion
mapping parser throws an error but it refers to the next field in the
document, not the field with the completion type.

I created a simple Gist to demonstrate the problem.

https://gist.github.com/glade-at-gigwell/6408e0e4b69ddf2e8856

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d47721f2-1798-4dba-b88f-3b923db037dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello,

I am experiencing the same problem: I am indexing a field (libelleVoie)
with a mapping of type completion, but this field is sometimes null, and
then I get this error:

[2014-08-25 13:16:49,500][DEBUG][action.bulk ] [gqa-es-node-1]
[fiche_immeuble][4] failed to execute bulk item (index) index
{[fiche_immeuble][terrain][0200000002],
source[{"id":350,"numero":"0200000002","numeroVoie":null,"libelleVoie":null,"commune":{"codePostal":"02130","codeInsee":"02127","libelle":"BRUYERES
SUR FERE"}}]}
org.elasticsearch.index.mapper.MapperParsingException: failed to parse
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:536)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:462)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:394)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:413)

    at 

org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:155)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:534)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:433)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException: Unknown
field name[commune], must be one of [context, payload, input, weight,
output]
at
org.elasticsearch.index.mapper.core.CompletionFieldMapper.parse(CompletionFieldMapper.java:256)
at
org.elasticsearch.index.mapper.core.AbstractFieldMapper$MultiFields.parse(AbstractFieldMapper.java:927)
at
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:422)
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeNullValue(ObjectMapper.java:526)
at
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:486)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:515)
... 9 more

Is there a worlaround (using ES 1.2.2)?

Gérald

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/104f8954-cebf-4def-aff1-56342ca0b80b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Replacing null by " " (espace) does the job.

Gérald

Le lundi 25 août 2014 13:51:12 UTC+2, Gérald Quintana a écrit :

Hello,

I am experiencing the same problem: I am indexing a field (libelleVoie)
with a mapping of type completion, but this field is sometimes null, and
then I get this error:

[2014-08-25 13:16:49,500][DEBUG][action.bulk ]
[gqa-es-node-1] [fiche_immeuble][4] failed to execute bulk item (index)
index {[fiche_immeuble][terrain][0200000002],
source[{"id":350,"numero":"0200000002","numeroVoie":null,"libelleVoie":null,"commune":{"codePostal":"02130","codeInsee":"02127","libelle":"BRUYERES
SUR FERE"}}]}
org.elasticsearch.index.mapper.MapperParsingException: failed to parse
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:536)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:462)
at
org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:394)
at
org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:413)

    at 

org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:155)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:534)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:433)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException:
Unknown field name[commune], must be one of [context, payload, input,
weight, output]
at
org.elasticsearch.index.mapper.core.CompletionFieldMapper.parse(CompletionFieldMapper.java:256)
at
org.elasticsearch.index.mapper.core.AbstractFieldMapper$MultiFields.parse(AbstractFieldMapper.java:927)
at
org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:422)
at
org.elasticsearch.index.mapper.object.ObjectMapper.serializeNullValue(ObjectMapper.java:526)
at
org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:486)
at
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:515)
... 9 more

Is there a worlaround (using ES 1.2.2)?

Gérald

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c61f3b19-0d99-4bf3-b72a-a1cf0bc67534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.