The default behavior of ES for null values ββis not to add a field value at all. However, you can set the default null_value value instead in your mapping. So in your case:
... "properties" : { ... "popularity" : { "type" : "integer", "null_value" : "0"
Link: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html
"When a field has (JSON) null, use null_value as the field value. By default, the field is not added at all."
I am surprised that ES does not throw any errors. You must confirm that in fact the documents (or not) have a βpopularityβ field. Try using Sense?
If you try to compute in a nonexistent field, I am sure that the ES will throw an exception [Missing value for field [x]]. This is both from my own experience and from checking the source code that implements field_value_factor:
https://gitlab.devero.com/development/elasticsearchssl/commit/8fbd1bdd489a9d31d3bda249c3ed9715052e196d
Scroll down to: src / main / java / org / elasticsearch / general / Lucene / search / function / FieldValueFactorFunction.java
and see lines 53-87.
source share