我想尝试一下scaled_floatElasticsearch,但无法理解以下内容:
如果我按照文档中的方式为索引创建映射:
PUT my_index
{
"mappings": {
"my_type": {
"properties": {
"price": {
"type": "scaled_float",
"scaling_factor": 100
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我向索引添加一些数据,如下所示:
PUT my_index/my_type/1
{
"price" : 100.1599999999
}
Run Code Online (Sandbox Code Playgroud)
我希望得到回报的价格100.16,但结果GET my_index/my_type/1显示:
{
"_index": "my_index",
"_type": "my_type",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"price": 100.1599999999
}
}
Run Code Online (Sandbox Code Playgroud)
为什么不是圆角的?
或者舍入值仅在索引中使用,我在这里看到的是保存的原始输入,因为它位于“_source”下?如何检查是否发生舍入?
我正在使用 Elasticsearch 5.6.5 和 Lucene 6.6.1
提前致谢!
然而,无论您在 中索引什么都_source不会改变,下面的价格将被索引为 100.16
如果运行此查询,您将看到 100.16 而不是 100.1599999999
GET my_index/_search
{
"size": 0,
"aggs": {
"avg": {
avg": {
"field": "price"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3688 次 |
| 最近记录: |