ElasticSearch 中 nested 类型聚合查询语句


建索引:
PUT es_latent_buy_brands_frequency {
"settings": { "number_of_replicas": 1 , "number_of_shards": 3 }, "mappings": { "doc": { "properties": { "user_id":{ "type": "keyword" }, "latent_buy_brand_frequency":{ "type": "nested", "properties": { "name":{ "type":"keyword" } } } } } } }
查询索引内数据: POST es_latent_buy_brands_frequency
/_search
查看mapping: GET es_latent_buy_brands_frequency
/_mapping
term查询: POST es_latent_buy_brands_frequency
/_search { "query": { "term": { "user_id": { "value": "1750119" } } } }
聚合查询: POST es_latent_buy_brands_frequency
/_search { "aggs": { "buy_goods_brand": { "nested": { "path": "latent_buy_brand_frequency" }, "aggs": { "agg_by_buy_goods_brand": { "terms": { "field": "latent_buy_brand_frequency.name", "size": 10 } } } } } }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM