Thank you for the reply, much appreciated.
As you say, if I use the search that you cite, the response contains the truncated doc value. For example, for a field that is mapped to long
:
"_source" : {
...
"myfield" : 3.14159
...
},
"fields" : {
"myfield" : [3]
}
Are the Elastic docs wrong?
From the Elastic docs for doc_values
:
Doc values [...] store the same values as the _source
That statement is demonstrably false, as shown in the example response above. The doc value is 3
, but the _source
value is 3.14159
.
Perhaps I’m still missing something; or perhaps I’m applying a too-literal interpretation to the phrase “same values”.
Do you think that statement in the docs is correct? Or do you think it requires rewording, or qualification?
An example
To confirm that I’ve understood what you’ve told me...
In an index where the field myfield
is mapped to the data type long
, I have two documents: in one document, the _source
value of myfield
is the integer value 12
; in the other document, the _source
value of myfield
is the floating-point value 12.5
.
If I send the following request:
GET my_index/_search
{
"query": {
"range" : {
"myfield" : {
"gte" : 12.2,
"lte" : 12.8
}
}
}
}
I get zero hits. That is, it doesn’t find the 12.5
.
If I’ve understood you correctly, this is because Elasticsearch is applying the query to the doc values that have been truncated due to the long
mapping. Am I right?
Kibana
For an index containing _source
values for myfield
of 3.14159
, 12
, and 12.5
, a Kibana search with myfield
added as a column—that is, the Kibana URL specifies columns:!(myfield)
—shows the following column values:
3.142
12.5
12
So, it seems that Kibana is displaying values from _source
(albeit rounded to the precision specified by the default pattern for the number format), not the doc values.
However, entering the following in the search field of the Discovery page:
myfield:(>12 AND <13)
gets “No results found”, because that search is based on the doc values.
I don’t mean to try your patience—you’ve already been very helpful; thanks again—but can you shed any light on why Kibana does not show doc values? Because it seems to me there’s a disconnect between the (_source
) values that Kibana shows and the (doc) values that are used to determine what Kibana shows.