欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Fielddata is disabled on text fields by default报错

程序员文章站 2022-07-14 22:32:05
...

学习es的时候,进行分组查询

GET /ecommerce/product/_search
{
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags"
      }
    }
  }
}

报错:
Fielddata is disabled on text fields by default报错按照教程修改:

PUT /ecommerce/_mapping/product
{
  "properties": {
    "tags": {
      "type": "text",
      "fielddata": true
    }
  } 
}

还是有问题:
Fielddata is disabled on text fields by default报错后面找到资料,加入关键字keyword即可搜索:

GET /ecommerce/product/_search
{
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags.keyword"
      }
    }
  }
}

问题解决

相关标签: es