2013-09-27 46 views
0

好了,這是任務:ElasticSearch:多場「升級」產量錯誤:

我已經閱讀整個文檔和我注意到,我可以「升級」之類的字符串數據類型的多場 - 在測試場景中它已經工作。

我的文檔結構是目前:使用默認映射創建

{ 
    "name": "test", 
    "words": [ 
     { 
      "words": "hello world", 
      "verts": [ 
       1, 
       2, 
       3 
      ] 
     } 
    ] 
} 

這些文件 - 這樣的映射關係已經明確設置。

我發出帶有類似數據的XDELETE命令:

{ 
    "article": { 
     "properties": { 
      "words": { 
       "type": "multi_field", 
       "fields": { 
        "words": { 
         "type": "string", 
         "index": "analyzed" 
        }, 
        "untouched": { 
         "type": "string", 
         "index": "not_analyzed" 
        } 
       } 
      } 
     } 
    } 
} 

但我這裏收到此錯誤:

{"error":"MergeMappingException[Merge failed with failures {[Can't merge a non multi_field/non simple mapping [words] with a multi_field mapping [words]]}]","status":400}

有人能向我解釋,爲什麼出現這種情況?當我將這個映射發佈到一個乾淨的索引時,它會起作用,並且正在應用not_analyzed過濾器。

謝謝:)

回答

1

因爲你的文檔中的「字」字段都有自己的屬性(「言」和「綠黨」),你不能「升級」到一個multi_field。然而,如果你有像

{ 
"article": { 
    "properties": { 
     "words": { 
      "properties": { 
       "words": { 
        "type": "multi_field", 
        "fields": { 
         "words": { 
          "type": "string", 
          "index": "analyzed" 
         }, 
         "untouched": { 
          "type": "string", 
          "index": "not_analyzed" 
         } 
        } 
       } 
      } 
     } 
    } 
} 
} 

然後一切都應該工作。

+0

正確,很好的答案! – javanna

+0

嗨,大家,對於遲到的回覆感到抱歉。這個答案是正確的。它與所有嵌套的jsons有點糾結:)我自己非常接近答案,但感到困惑。謝謝克里斯! – Jan