小编Kri*_*thi的帖子

嵌套聚合elasticsearch,具有用于子聚合的访问父字段

我有以下映射

PUT prod_nested
{
  "mappings": {
    "default": {
      "properties": {
        "pkey": {
          "type": "keyword"
        },
        "original_price": {
          "type": "float"
        },
        "tags": {
          "type": "nested",
          "properties": {
            "category": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 30
                }
              }
            },
            "attribute": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 30
                }
              }
            },
            "original_price": {
              "type": "float"
            }
          }
        }
      }
    }
  } 
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试做类似以下 sql 聚合的事情

select tag_attribute,
       tag_category,
       avg(original_price)
FROM products
GROUP BY tag_category, tag_attribute …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

2
推荐指数
1
解决办法
1030
查看次数

标签 统计

elasticsearch ×1