建索引:
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
}
}
}
}
}
}