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