ElasticSearch retrieves all fields, even if their value is zero

I want to search for ElasticSearch and extract specific fields from all records, regardless of their value. But the answer contains for each record only fields whose value is not null . Is there a way to get ElasticSearch to return the exact number of fields for all records?

Request example:

{ "fields" : ["Field1","Field2","Field3"], "query" : { "match_all" : {} } } 

Answer example:

 { "hits": [ { "fields": { "Field1": [ "bla" ], "Field2": [ "test" ] } }, { "fields": { "Field1": [ "bla" ], "Field2": [ "test" ], "Field3": [ "somevalue" ] } } ] } 

My goal is to get something for "Field3" in the first hit.

+6
source share
1 answer

In accordance with the guidance provided in the following link, it clearly states that any fields that are null, [] or "" are not saved or indexed in the document. Its concept is an inverted index and must be handled explicitly in the program.

link - http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_dealing_with_null_values.html

0
source

Source: https://habr.com/ru/post/975296/


All Articles