c# - Elasticsearch 5.6:路径 [xxxxxx] 下的 [nested] 嵌套对象不是嵌套类型
问题描述
我正在尝试升级到 elasticsearch 5.6,并且在执行请求时收到以下错误。它在我们运行多年的早期版本中运行良好。有任何想法吗?
{"type":"illegal_state_exception","reason":"[nested] 路径 [categories] 下的嵌套对象不是嵌套类型"}
这是我的映射:
.Mappings(mappings => mappings
.Map<ESProduct>(product => product
.AutoMap()
.Properties(prop1 => prop1
.Nested<ESCategory>(n => n
.Name("categories")
.AutoMap()
.Properties(props => props
.Keyword(s => s.Name(p => p.Id).Index())
.Keyword(s => s.Name(p => p.Name).Index())
.Text(s => s.Name(p => p.Path)
.Analyzer("path_analyzer")
.Index()
)
.Text(s => s.Name(p => p.IdNamePath)
.Fielddata(true)
.Analyzer("path_analyzer")
.Index()
)
)
)
我的要求是这样的:
{
"aggs":{
"agg_manufacturers":{
"terms":{
"field":"manufacturer.idName",
"size":10000
}
},
"cat_nest":{
"aggs":{
"agg_categories":{
"terms":{
"field":"categories.idNamePath",
"include":"/10000.*",
"size":10000
}
}
},
"nested":{
"path":"categories"
}
}
},
"query":{
"bool":{
"must":[
{
"nested":{
"path":"categories",
"query":{
"term":{
"categories.path":{
"value":"10000/13168"
}
}
}
}
},
{
"bool":{
"should":[
{
"term":{}
}
]
}
},
{
"term":{}
}
]
}
},
"size":0
}
我的映射:
{
"my-index": {
"mappings": {
"product": {
"properties": {
"categories": {
"properties": {
"autoKeywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"displayOrder": { "type": "long" },
"id": { "type": "long" },
"idName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"idNamePath": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"isFeatured": { "type": "boolean" },
"manualSort": { "type": "boolean" },
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"namePath": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"parentID": { "type": "long" },
"path": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"showProduct": { "type": "boolean" },
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"manufacturer": {
"properties": {
"displayOrder": { "type": "long" },
"id": { "type": "long" },
"idName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"imageUrl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"isFeatured": { "type": "boolean" },
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
}
调试信息:
Invalid NEST response built from a unsuccessful low level call on PUT: /my-index
# Audit trail of this API call:
- [1] BadResponse: Node: https://domain.../ Took: 00:00:00.6376279
# ServerError: ServerError: 400Type: illegal_argument_exception Reason: "mapper [title] cannot be changed from type [text] to [keyword]"
# OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at Elasticsearch.Net.HttpWebRequestConnection.Request[TReturn](RequestData requestData)
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
# Response:
<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
解决方案
推荐阅读
- spring-boot - 使Springboot应用程序Pod自动删除
- java - Java异常堆栈跟踪有“$ 8”,这是什么意思?
- node.js - 当 TypeScript 中有多个返回类型时,如何检查对象的类型?
- html - 如果里面的文本很长,CSS按钮会被推出
- javascript - 在 JavaScript 中使用 .map() 渲染列表时如何分隔元素?
- python - TensorFlow io.decode_csv 并沿一维选择数据
- php - 如何使具有不同产品 ID 的两种产品在 WooCommerce 购物车页面(BOGO)上充当一个
- amazon-web-services - 使用增加卷大小的 powershell 启动新的 ec2 实例
- java - 无法从 AsyncTask 访问 ProgressBar
- python - Gekko 求解器不提供任何解决方案