首页 > 解决方案 > Elasticsearch 5.6:路径 [xxxxxx] 下的 [nested] 嵌套对象不是嵌套类型

问题描述

我正在尝试升级到 elasticsearch 5.6,并且在执行请求时收到以下错误。它在我们运行多年的早期版本中运行良好。有任何想法吗?

{"type":"illegal_state_exception","re​​ason":"[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.>

标签: c#elasticsearchnestelasticsearch-5

解决方案


推荐阅读