admin管理员组文章数量:1640615
Fielddata is disabled on text fields by default. Set fielddata=true
目录
问题:
处理:
语法
找my_type
试错:
使用 提示的type
总结:
问题:
使用es语句进行排序查询的时候,
GET /basic_index*/_search
{
"size": 20,
"from": 0,
"sort": [
{
"state": {
"order": "desc"
}
}
]
}
报错信息:
处理:
这时候需要设置fidlddata:fielddata:true
文档里面:
语法
PUT my_index/_mapping/my_type
{
"properties": {
"my_field": {
"type": "text",
"fielddata": true
}
}
}
my_index,my_field 好理解,分别对应上面的: basic_index 和 state
my_type 就不懂对应哪个了,文档里面也没有具体的说明,该怎么找呢?
找my_type
不知道哪个,就试试好了,试试text
试错:
PUT basic_index/_mapping/text
{
"properties": {
"state": {
"type": "text",
"fielddata": true
}
}
}
错误信息:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [basic_index] as the final mapping would have more than 1 type: [text, basic_type]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [basic_index] as the final mapping would have more than 1 type: [text, basic_type]"
},
"status": 400
}
里面提示了是basic_type,这个可能就是想要的my_type
使用 提示的type
PUT basic_index/_mapping/basic_type
{
"properties": {
"state": {
"type": "text",
"fielddata": true
}
}
}
添加成功:
再点击查询,就可以查询到数据了,目的达成。
总结:
Es根据某个字段查询,有时候不支持,是因为没有开启,需要设置 fielddata:true 。不知道my_type对应什么,就用过试错的方法,根据提示来修改。有时候找不到就多试试,看看错误的提示,也许可以找到对应的内容。
关联文章: 设置数组类型内字段的排序
本文标签: TextFieldsFielddatadisabled
版权声明:本文标题:Fielddata is disabled on text fields by default. Set fielddata=true 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729320093a1195777.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论