Field null_value doesn't seem to have any effect?

Hello,

I've configured the null_value of a field, as below. But when I do a query,
the documents that lack a barfield, don't return the value "0" for the
'barfield' as expected. What could be the reason?

"foo": {
    "properties": {
        "barfield": {
            "type": "long",
            "store" : true,
            "null_value" : 0
        },
}

Regards,

AS.

--
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/509da3e8-0f77-473d-b8e7-becd835f5221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

The null_value is not used as a "default value", but as a value to used
when doing searching or aggregations.

For instance, in your mapping, your document will match if you have a
filter like this: ['term' => ['barfield' => 0]], however it won't return
the barfield property if it is null.

--
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/8a652e81-2b87-4857-a06c-c522c0fa7bc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ah, that explains it. Thx. How can I configure / simulate a default_value
for this field?

/AS

On Friday, February 6, 2015 at 4:41:01 PM UTC+1, Michaël Gallego wrote:

The null_value is not used as a "default value", but as a value to used
when doing searching or aggregations.

For instance, in your mapping, your document will match if you have a
filter like this: ['term' => ['barfield' => 0]], however it won't return
the barfield property if it is null.

--
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/3b7d8f0b-f8c6-471f-a8bf-c94346603fad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Just adding to the previous answer that elasticsearch does not modify the _source doc.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 6 févr. 2015 à 16:32, AS *@equanimity.nl a écrit :

Hello,

I've configured the null_value of a field, as below. But when I do a query, the documents that lack a barfield, don't return the value "0" for the 'barfield' as expected. What could be the reason?

"foo": {
    "properties": {
        "barfield": {
            "type": "long",
            "store" : true,
            "null_value" : 0
        },
}

Regards,

AS.

--
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/509da3e8-0f77-473d-b8e7-becd835f5221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/F4EFA1AC-EAE4-4124-944F-3A81E08465B6%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.