Elasticsearch - 对象映射[menu]无法从嵌套更改为非嵌套

时间:2018-04-29 13:32:42

标签: java elasticsearch mapping elasticsearch-5

我正在尝试在Elasticsearch 6.2中索引文档。 dynamic mapping menu事情按预期工作。有两个嵌套对象address{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "object mapping [menu] can't be changed from nested to non-nested" } ], "type": "illegal_argument_exception", "reason": "object mapping [menu] can't be changed from nested to non-nested" }, "status": 400 。当我尝试索引文档时,会出现以下错误。

{
  "settings": {
    "analysis": {
      "filter": {
        "autocomplete_filter": {
          "type": "edge_ngram",
          "min_gram": 2,
          "max_gram": 10
        }
      },
      "analyzer": {
        "autocomplete": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "autocomplete_filter"
          ]
        }
      }
    }
  },
  "mappings": {
    "type_name": {
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "text",
            "analyzer": "autocomplete"
          },
          "description": {
            "type": "text"
          },
          "phone_number": {
            "type": "text"
          },
          "cuisine": {
            "type": "text",
            "analyzer": "autocomplete"
          },
          "eat": {
            "type": "text",
            "analyzer": "autocomplete"
          },
          "rating": {
            "type": "float"
          },
          "address": {
            "type": "nested",
            "properties": {
              "city": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "area": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "pincode": {
                "type": "keyword",
                "index": "false"
              },
              "coordinate": {
                "type": "geo_point"
              },
              "full_address": {
                "type": "text"
              }
            }
          },
          "menu": {
            "type": "nested",
            "properties": {
              "id": {
                "type": "integer"
              },
              "dish_name": {
                "type": "text",
                "analyzer": "autocomplete"
              },
              "category": {
                "type": "text"
              },
              "price": {
                "type": "float"
              }
            }
          }
        }
      }
    }
  }

}

http://localhost:9200/index_name/type_name/1

映射详情:

{
  "id" : 1,
  "name" : "Nagarjuna ",
  "description" : "The Description",
  "phone_number" : ["835555558"],
  "address" : [{
    "city" : "Bangalore",
    "area" : "Marathahalli",
    "pincode" : "560030",
    "full_address" : "88, Outer Ring Road, Next to MORE MEGA Store, Marathahalli, Bangalore",
    "coordinate" : "12.973157, 77.608940"
  }],
  "rating" : "4",
  "eat" : "Non Veg",
  "menu" : [
    {
      "id" : 1,
      "category" : "Dosa",
      "dish_name" : "Plain Dosa",
      "price" : 130
    },
    {
      "id" : 2,
      "category" : "Dosa",
      "dish_name" : "Onion Dosa",
      "price" : 150
    },
    {
      "id" : 3,
      "category" : "Dosa",
      "dish_name" : "Set Dosa",
      "price" : 150
    },
    {
      "id" : 4,
      "category" : "Dosa",
      "dish_name" : "Rava Dosa",
      "price" : 180
    },
    {
      "id" : 5,
      "category" : "Dosa",
      "dish_name" : "Masala Dosa",
      "price" : 150
    },
    {
      "id" : 6,
      "category" : "Briyani",
      "dish_name" : "Chicken Briyani",
      "price": 250
    },
    {
      "id" : 7,
      "category" : "Briyani",
      "dish_name" : "Muton Briyani",
      "price": 280
    }
  ]
}

文件详情:

@elseif(optional($Tenancy)->addTenancy())

长时间调试,但徒劳无功。请帮忙。

0 个答案:

没有答案