(please try not to paste text as images... hard to see, help, debug etc...etc. paste as formatted text)
But YUP You need to use a double
as the type not float
as you are exceeding the significant digits of a single precision float
Also you are confusing the _source
(what comes in the source json) and the fields
what is index stored and showed in the Discover, Visualizations.. etc
Here follow along
What you have now
PUT discuss-test/
{
"mappings" : {
"properties": {
"@timestamp": {
"type": "date"
},
"balance": {
"type": "float"
}
}
}
}
POST discuss-test/_doc
{
"@timestamp" : "2022-12-22T17:44:11.891Z",
"balance" : 11555.7125
}
POST discuss-test/_doc
{
"@timestamp" : "2022-12-22T17:45:11.891Z",
"balance" : 11666.7725
}
GET discuss-test/_search
{
"fields": [
"*"
]
}
#Results Notice the difference between the `_source` and the `fields`
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "discuss-test",
"_id": "xkOxPIUBrWRX1Zc6vqbo",
"_score": 1,
"_source": {
"@timestamp": "2022-12-22T17:44:11.891Z",
"balance": 11555.7125 <!------ _source what you sent
},
"fields": {
"@timestamp": [
"2022-12-22T17:44:11.891Z"
],
"balance": [
11555.713 <!- Single Precision Float :( what was stored and used
]
}
},
{
"_index": "discuss-test",
"_id": "x0OxPIUBrWRX1Zc6vqb5",
"_score": 1,
"_source": {
"@timestamp": "2022-12-22T17:45:11.891Z",
"balance": 11666.7725
},
"fields": {
"@timestamp": [
"2022-12-22T17:45:11.891Z"
],
"balance": [
11666.772
]
}
}
]
}
}
Now lets do it with a double
DELETE discuss-test
PUT discuss-test/
{
"mappings" : {
"properties": {
"@timestamp": {
"type": "date"
},
"balance": {
"type": "double"
}
}
}
}
POST discuss-test/_doc
{
"@timestamp" : "2022-12-22T17:44:11.891Z",
"balance" : 11555.7125
}
POST discuss-test/_doc
{
"@timestamp" : "2022-12-22T17:45:11.891Z",
"balance" : 11666.7725
}
GET discuss-test/_search
{
"fields": [
"*"
]
}
# Results Happy Days!
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "discuss-test",
"_id": "ykOzPIUBrWRX1Zc6kaYi",
"_score": 1,
"_source": {
"@timestamp": "2022-12-22T17:44:11.891Z",
"balance": 11555.7125 <!--- Source
},
"fields": {
"@timestamp": [
"2022-12-22T17:44:11.891Z"
],
"balance": [
11555.7125 <!--- Stored Field
]
}
},
{
"_index": "discuss-test",
"_id": "y0OzPIUBrWRX1Zc6kaYu",
"_score": 1,
"_source": {
"@timestamp": "2022-12-22T17:45:11.891Z",
"balance": 11666.7725
},
"fields": {
"@timestamp": [
"2022-12-22T17:45:11.891Z"
],
"balance": [
11666.7725
]
}
}
]
}
}
And Discover