2011-11-16 30 views
31

我下面,以便找到部分字詞與elasticsearch這裏給出的建議是:Elasticsearch總是返回「映射類型缺少」

ElasticSearch n-gram tokenfilter not finding partial words

我已經創建了一個試圖運行一個簡單的bash腳本一個版本是:

curl -XDELETE 10.160.86.134:9200/products 
curl -XPOST 10.160.86.134:9200/products -d '{ 
    "index": { 
    "number_of_shards": 1, 
    "analysis": { 
     "filter": { 
     "mynGram" : {"type": "nGram", "min_gram": 2, "max_gram": 10} 
     }, 
     "analyzer": { 
     "a1" : { 
      "type":"custom", 
      "tokenizer": "standard", 
      "filter": ["lowercase", "mynGram"] 
     } 
     } 
    } 
    } 
    } 
}' 

curl -XPUT 10.160.86.134:9200/products/_mapping -d '{ 
    "product" : { 
    "index_analyzer" : "a1", 
    "search_analyzer" : "standard", 
    "properties" : { 
     "product_description": {"type":"string"}, 
     "product_name": {"type":"string"} 
    } 
    } 
}' 

以下運行此腳本的前兩個命令(傾銷產品,然後設定指數)似乎工作給我這個:

{"ok":true,"acknowledged":true} 
{"ok":true,"acknowledged":true} 

然後出現了錯誤以下映射調用給我這個:

{"error":"ActionRequestValidationException[Validation Failed: 1: mapping type is missing;]","status":500} 

有人能看到我在做什麼錯?搜索谷歌開始autocompleting「映射未找到elasticsearch」,所以它似乎是一個非常常見的錯誤。

+1

elasticsearch仍然是一個年輕的項目,文檔越來越多,但仍然缺乏。我通常會在郵件列表中獲得很好的回覆,https://groups.google.com/group/elasticsearch – Andy

回答

72

原來,這種情況正在發生,因爲映射需要被應用到該類型:

我試圖把它應用到了錯誤的事情:

curl -XPUT 10.160.86.134:9200/products/_mapping -d '{ 

它需要被應用到該類型像這樣:

curl -XPUT 10.160.86.134:9200/products/product/_mapping -d '{ 

很遺憾,簡單的谷歌搜索無法回答這個問題。此外,我鏈接到的以前的帖子是非常誤導,答案是錯誤的,我也會指出。

+5

我與您同在。在彈性搜索方面似乎還不夠。文檔沒有太大的幫助,搜索並沒有太多幫助。我在_routing時遇到了錯誤,無法在任何地方找到答案。我也沒有嘗試過IRC,但它可能會有所幫助。 – swatkins

+0

我同意你re:文檔,但我相信這是一個最近(當你問)更改爲[以前你可以'放'一個映射到索引和包含文檔類型的映射JSON](https:// groups.google.com/a/elasticsearch.com/d/msg/users/_i2sVYlCsrI/5n2tqMa-DXEJ)...文檔正在變得更好,但它仍然不是所有的方式 – Basic

+0

鏈接到[文檔](https:/ /www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)以供參考。 – yurez

相關問題