field null_value doesn't seem to have any effect?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

field null_value doesn't seem to have any effect?

AS-2
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: field null_value doesn't seem to have any effect?

Michaël Gallego
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: field null_value doesn't seem to have any effect?

AS-2
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 [hidden email].
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.
Reply | Threaded
Open this post in threaded view
|

Re: field null_value doesn't seem to have any effect?

dadoonet
In reply to this post by AS-2
Just adding to the previous answer that elasticsearch does not modify the _source doc.

--
David ;-)
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 [hidden email].
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 [hidden email].
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.