2016-10-04 57 views
0

我想索引一個文檔在elasticsearch中。我所使用的json來自正在從XML轉換爲JSON的文檔。這是有效的JSON。看起來像這樣:索引json與彈性搜索中的json值

{ 
     "shortcasename": { 
      "_attributes": { 
       "party1": "People", 
       "party2": "Johnson" 
      }, 
      "_children": [ 
       "People", 
       { 
        "connector": { 
         "_attributes": { 
          "normval": "v" 
         }, 
         "_children": [ 
          " v. " 
         ] 
        } 
       }, 
       "Johnson" 
      ] 
     } 
    } 

Elasitcsearch似乎有一個shortcasename._children問題。我得到的錯誤是:

{ 
    "error": { 
     "root_cause": [ 
     { 
      "type": "mapper_parsing_exception", 
      "reason": "failed to parse" 
     } 
     ], 
     "type": "mapper_parsing_exception", 
     "reason": "failed to parse", 
     "caused_by": { 
     "type": "illegal_argument_exception", 
     "reason": "mapper [shortcasename._children] of different type,  current_type [string], merged_type [ObjectMapper]" 
     } 
    }, 
    "status": 400 
} 

有沒有辦法讓json被索引的方式呢?

回答

0

的你有JSON具有與_children領域的衝突:

{ 
    "shortcasename": { 
    "_attributes": { 
     "party1": "People", 
     "party2": "Johnson" 
    }, 
    "_children": [ 
     "People", 
     { 
     "connector": { 
      "_attributes": { 
      "normval": "v" 
      }, 
      "_children": [ 
      " v. " 
      ] 
     } 
     }, 
     "Johnson" 
    ] 
    } 
} 

頂層_children字段是包含對象({"connector": ...})和字符串的混合陣列("People"Johnson")Elasticsearch。不支持,這就是爲什麼它抱怨說它不能合併stringObject

+0

有沒有這樣的運氣? – Val