2015-09-11 137 views
0

忽略場我試圖創造彈性搜索的映射忽略我的輸入數據的領域之一。我在這裏下的文檔彈性搜索如何映射

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

看起來像enabled屬性正是我需要的,但我沒有得到預期的效果。

這裏是我的映射

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" 
       } 
      } 
     } 
     } 

} 

這裏是我的數據

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" 
    } 

,我得到以下錯誤

{ 
    "error": "MapperParsingException[failed to parse [FIXMessage.448]]; nested: NumberFormatException[For input string: \"ew\"]; ", 
    "status": 400 
} 

爲什麼沒有現場忽視?

注:

我也曾嘗試以下屬性

「存儲」:假的, 「include_in_all」:假的, 「指數」: 「無」

,但沒有效果。

回答

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" 
    } 

或映射改變typet爲:

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" 
      } 
     } 
    } 
    } 

    } 
+0

原來如此!謝謝 – AbtPst