弹性搜索如何忽略映射中的字段

Abt*_*Pst 0 lucene elasticsearch elasticsearch-indices

我试图在弹性搜索中创建一个映射,以忽略我的传入数据中的一个字段.我在这里关注文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-object-type.html#_enabled_3

看起来启用属性正是我需要的,但我没有得到预期的结果.

这是我的映射

PUT /comtest
{

      "mappings": {
         "ftype": {

            "properties": {
               "a": {
                  "type": "string"
               },
               "b": {
                  "type": "long"
               },

               "c":
               {
                "type" : "object",
                        "enabled" : false
               },
               "d": {
                  "type": "string"
               },
               "e": {
                  "type": "string"
               },
               "f": {
                  "type": "boolean"
               },
               "g": {
                  "type": "string"
               },
               "h": {
                  "type": "string"
               },
               "i": {
                  "type": "long"
               },
               "j": {
                  "type": "string"
               },
               "k": {
                  "type": "long"
               },
               "l": {
                  "type": "date"
               },
               "m": {
                  "type": "string"
               },
               "n": {
                  "type": "string"
               },
               "o": {
                  "type": "string"
               },
               "p": {
                  "type": "string"
               }
            }
         }
      }

}
Run Code Online (Sandbox Code Playgroud)

这是我的数据

put /comtest/t/1
{
    "a": "cdcwc",
    "b": 1,
    "c": {
        "6": 22,

        "322": [
            444,
            "ew",
            "fwefwe."
        ]
    },
    "d": null,
    "e": "svgerbgerb",
    "f": false,
    "g": "rethrt",
    "h": null,
    "i": 55,
    "j": null,
    "k": null,
    "l": null,
    "m": "dasd",
    "n": 88,
    "o": "1",
    "p": "asas"
    }
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

{
   "error": "MapperParsingException[failed to parse [FIXMessage.448]]; nested: NumberFormatException[For input string: \"ew\"]; ",
   "status": 400
}
Run Code Online (Sandbox Code Playgroud)

为什么这个领域不被​​忽视?

注意:

我也尝试了以下属性

"store":false,"include_in_all":false,"index":"no"

但没有效果.

Dha*_*pil 5

因为您已为类型定义了映射,ftype并且您正在为类型编制索引t.

将添加的文档类型更改ftype为:

put /comtest/ftype/1
{
    "a": "cdcwc",
    "b": 1,
    "c": {
        "6": 22,

        "322": [
            444,
            "ew",
            "fwefwe."
        ]
    },
    "d": null,
    "e": "svgerbgerb",
    "f": false,
    "g": "rethrt",
    "h": null,
    "i": 55,
    "j": null,
    "k": null,
    "l": null,
    "m": "dasd",
    "n": 88,
    "o": "1",
    "p": "asas"
    }
Run Code Online (Sandbox Code Playgroud)

或者将type映射更改t为:

  PUT /comtest
  {

  "mappings": {
     "t": {

        "properties": {
           "a": {
              "type": "string"
           },
           "b": {
              "type": "long"
           },

           "c":
           {
            "type" : "object",
                    "enabled" : false
           },
           "d": {
              "type": "string"
           },
           "e": {
              "type": "string"
           },
           "f": {
              "type": "boolean"
           },
           "g": {
              "type": "string"
           },
           "h": {
              "type": "string"
           },
           "i": {
              "type": "long"
           },
           "j": {
              "type": "string"
           },
           "k": {
              "type": "long"
           },
           "l": {
              "type": "date"
           },
           "m": {
              "type": "string"
           },
           "n": {
              "type": "string"
           },
           "o": {
              "type": "string"
           },
           "p": {
              "type": "string"
           }
        }
     }
  }

  }
Run Code Online (Sandbox Code Playgroud)