码迷,mamicode.com
首页 > 其他好文 > 详细

ES技巧

时间:2019-10-31 21:42:00      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:统计   rms   href   bucket   uid   html   ide   arch   paginati   

2,

统计字段b的不同值的数量

{"size":0,"aggs":{"distinct_colors":{"cardinality":{"field":"b"}}}}

 

统计字段Local_ip的不同值

{"size":0,"aggs":{"langs":{"terms":{"field":"Local_ip","size":50000000}}}}

 

3,

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html

GET /products5/_search

{"query":{"match":{"name":"led tv"}},"aggs":{"resellers":{"nested":{"path":"resellers"},"aggs":{"langs":{"terms":{"field":"resellers.price","size":50000000}}}}}}

 

GET /products5/_search

{"query":{"bool":{"must":[],"must_not":[],"should":[],"filter":[{"nested":{"path":"resellers","query":{"bool":{"must":[{"term":{"resellers.price":44}}],"must_not":[],"should":[],"filter":[]}}}}]}},"from":0,"size":10,"sort":[]}

 

4,

PUT /products5/_doc/13

{"name":"LED TV","resellers":[{"price":101},{"price":110},{"price":130}],"date":"2015/02/01 05:02:00"}

 

GET /products5/_search

{"query":{"match":{"name":"led tv"}},"aggs":{"sales_per_month":{"date_histogram":{"field":"date","fixed_interval":"60m"},"aggs":{"resellers":{"nested":{"path":"resellers"},"aggs":{"sales":{"terms":{"field":"resellers.price","size":50000000}}}}}}}}

 

ES 分页

https://www.elastic.co/guide/cn/elasticsearch/guide/current/pagination.html

https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-request-from-size.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html

ES技巧

标签:统计   rms   href   bucket   uid   html   ide   arch   paginati   

原文地址:https://www.cnblogs.com/WCFGROUP/p/11773679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!