elasticsearch 聚合函数 max double精度损失bug
测试样例数据
{
"size" : 0,
"query" : {
"bool" : {
"must" : {
"bool" : {
"must" : {
"bool" : {
"must" : {
"match" : {
"cankwxzwtm" : {
"query" : "丹参",
"type" : "phrase"
}
}
}
}
}
}
}
}
},
"aggregations" : {
"group_docid" : {
"terms" : {
"field" : "docid.raw",
"size" : 1000
},
"aggregations" : {
"maxid" : {
"max" : {
"field" : "longId"
}
}
}
}
}
}
测试结果数据
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 3,
"successful": 3,
"failed": 0
},
"hits": {
"total": 24,
"max_score": 0,
"hits": []
},
"aggregations": {
"group_docid": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "995922987708317699",
"doc_count": 4,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317703",
"doc_count": 2,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317708",
"doc_count": 2,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987712512006",
"doc_count": 2,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512012",
"doc_count": 2,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987704123392",
"doc_count": 1,
"maxid": {
"value": 995922987704123390
}
},
{
"key": "995922987708317700",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317701",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317704",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317705",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317706",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987708317709",
"doc_count": 1,
"maxid": {
"value": 995922987708317700
}
},
{
"key": "995922987712512002",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512007",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512009",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512010",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
},
{
"key": "995922987712512011",
"doc_count": 1,
"maxid": {
"value": 995922987712512000
}
}
]
}
}
}
总结:maxid.value的值精度已经损失,没去官网深究原因,用terms替换max方法,得出所有id值,手动筛选值。
elasticsearch 聚合函数 max double精度损失bug的更多相关文章
- js double 精度损失 bugs
js double 精度损失 bugs const arr = [ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 ]; // [ ...
- js 小数转整数,避免精度损失 bug
js 小数转整数,避免精度损失 bug const arr = [ 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01 ]; // ( ...
- java 常用类库:BigInteger大整数;BigDecimal大小数(解决double精度损失);
大整数BigInteger package com.zmd.common_class_libraries; import java.math.BigInteger; /** * @ClassName ...
- Java中关于 BigDecimal 的一个导致double精度损失的"bug"
背景 在博客 恶心的0.5四舍五入问题 一文中看到一个关于 0.5 不能正确的四舍五入的问题.主要说的是 double 转换到 BigDecimal 后,进行四舍五入得不到正确的结果: public ...
- GROUP BY 聚合函数(max min sum avg count) 和HAVING的 使用
重新复习一下这个都源自于我经常需要查的一个需求 “要找到表里面 出现了两次或者三次的某个字段” 现在假设有一张表字段是 +----+---------------------+------------ ...
- elasticsearch聚合函数
计算每个tag下的商品数量 GET /ecommerce/product/_search { "aggs": { //聚合 "group_by_tags": ...
- ElasticSearch 聚合函数
一.简单聚合 桶 :简单来说就是满足特定条件的文档的集合. 指标:大多数 指标 是简单的数学运算(例如最小值.平均值.最大值,还有汇总),这些是通过文档的值来计算. 桶能让我们划分文档到有意义的集合, ...
- oracle中的常用函数、字符串函数、数值类型函数、日期函数,聚合函数。
一.字符串的常用函数. --一.oracle 字符串常用函数 --1. concat 连接字符串的函数,只能连接[两个]字符串. 字符写在括号中,并用逗号隔开! --2."||"符 ...
- 第17课-数据库开发及ado.net 聚合函数,模糊查询like,通配符.空值处理.order by排序.分组group by-having.类型转换-cast,Convert.union all; Select 列 into 新表;字符串函数;日期函数
第17课-数据库开发及ado.net 聚合函数,模糊查询like,通配符.空值处理.order by排序.分组group by-having.类型转换-cast,Convert.union all; ...
随机推荐
- Coach Said No Worry
I have been losing memories those days. I can't get through what I was doing right then. I have prom ...
- PHP安全之webshell和后门检测(转)
基于PHP的应用面临着各种各样的攻击: XSS:对PHP的Web应用而言,跨站脚本是一个易受攻击的点.攻击者可以利用它盗取用户信息.你可以配置Apache,或是写更安全的PHP代码(验证所有用户输入) ...
- USB眼图
/********************************************************************** * USB眼图 * 说明: * 对于USB眼图,并不是很 ...
- 【leetcode】409. Longest Palindrome
problem 409. Longest Palindrome solution1: class Solution { public: int longestPalindrome(string s) ...
- JS中数据类型的判断
typeof 使用 : var n = "hello"; console.log(typeof n); console.log(typeof(n));
- [LeetCode&Python] Problem 606. Construct String from Binary Tree
You need to construct a string consists of parenthesis and integers from a binary tree with the preo ...
- golang相关网摘
1.golang开发50个坑 http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/index.html#mli ...
- Gym102040 .Asia Dhaka Regional Contest(寒假自训第9场)
B .Counting Inversion 题意:给定L,R,求这个区间的逆序对数之和.(L,R<1e15) 思路:一看这个范围就知道是数位DP. 只是维护的东西稍微多一点,需要记录后面的各种数 ...
- django-models层
----https://www.cnblogs.com/liuqingzheng/articles/9472723.html 一.ORM简介 查询数据层次图解:如果操作mysql,ORM是在pymys ...
- 【Wannafly挑战赛22A计数器】【裴蜀定理】
https://www.nowcoder.com/acm/contest/160/A 题目描述 有一个计数器,计数器的初始值为0,每次操作你可以把计数器的值加上a1,a2,...,an中的任意一个整数 ...