我正在尝试升级到Elasticsearch 5.6,并且在执行请求时遇到以下错误。在我们运行了多年的早期版本中,它运行良好。有什么想法吗?
{“类型”:“ illegal_state_exception”,“原因”:“ [嵌套]嵌套对象 路径[类别]下的不是嵌套类型“}
这是我的地图:
.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.>