当前位置:   article > 正文

es 字段截取聚合分组_es 聚合 script 字符串长度

es 聚合 script 字符串长度
  1. GET /mybooks/_search
  2. {
  3. "query": {
  4. "bool": {
  5. "must": [
  6. {
  7. "prefix": {
  8. "region_id": "11"
  9. }
  10. }
  11. ]
  12. }
  13. },
  14. "aggs": {
  15. "group_location": {
  16. "terms": {
  17. "script": {
  18. "source": "boolean b = doc['region_id'].size() > 0;String c = doc['region_id'].value;if (b && c.length() > 2){return c.substring(0, 2)}"
  19. },
  20. "size": 6
  21. },
  22. "aggs": {
  23. "group_ent": {
  24. "terms": {
  25. "field": "_id",
  26. "size": 6,
  27. "order": {
  28. "nest>total": "desc"
  29. }
  30. },
  31. "aggs": {
  32. "nest": {
  33. "nested": {
  34. "path": "info"
  35. },
  36. "aggs": {
  37. "total": {
  38. "sum": {
  39. "field": "info.money"
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. },
  49. "from": 0,
  50. "size": 0
  51. }

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/132675
推荐阅读
相关标签
  

闽ICP备14008679号