Q:有两个人掉到陷阱里了,死的人叫死人,活人叫什么?

es查询结果超过16位导致精度丢失

Elasticsearch | 作者 yaotou6364 | 发布于2019年09月25日 | 阅读数:4500

使用es查询长度为19位,且结尾4位为6123的push_id时,返回的结果4位是6000,也就是超过16位的结果精度丢失。已经确认数据是没问题的(用6123查得到,但是返回6000,使用6000查不到)
具体的索引mapping如下:
{
  "billlog_push_stat_report_2019-09-25": {
    "mappings": {
      "music": {
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "device_id": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "from_uid": {
            "type": "long"
          },
          "host": {
            "properties": {
              "name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "index_name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "input": {
            "properties": {
              "type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "latform": {
            "type": "long"
          },
          "ppid": {
            "type": "long"
          },
          "prospector": {
            "properties": {
              "type": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "push_id": {
            "type": "long"
          },
          "status": {
            "type": "long"
          },
          "task_id": {
            "type": "long"
          },
          "to_uid": {
            "type": "long"
          }
        }
      }
    }
  }
}
 
请问这种情况如何查询才能返回正确的结果呢?
企业微信截图_451406c8-07e5-4ec9-8f80-a5c265ed80de(1).png
已邀请:

kennywu76 - Wood

赞同来自: laoyang360 caizhongao

我在ES英文论坛问过这个问题
https://discuss.elastic.co/t/l ... 24/12 ,结论是javascript本身的限制导致ES的Dev Console显示的数值丢失精度,如果在命令行下用curl去查询就不会有问题。 

trycatchfinal

赞同来自:

ES是什么版本?
我在ES 7.1上测试没有问题

图像_3.png

 

mysia

赞同来自:

在6.x版本中,kibana的dev tools有精度限制,用api查询应该是对的

doom

赞同来自:

es版本6.8.1我的也没问题:

11.png

 

ELKer

赞同来自:

这个是js处理数字时精度丢失

要回复问题请先登录注册