2015-05-06 49 views
1

使用sense,我試圖爲具有三個屬性的索引創建映射。當我嘗試創建它,我得到以下響應MapperParsingException在爲elasticsearch索引創建映射時

{ 
    "error": "MapperParsingException[Root type mapping not empty after parsing! Remaining fields: [mappings : {gram={properties={gram={type=string, fields={gram_bm25={type=string, similarity=BM25}, gram_lmd={type=string}}}, sentiment={type=string, index=not_analyzed}, word={type=string, index=not_analyzed}}}}]]", 
    "status": 400 
} 

這是我在這個意義上控制檯

PUT /pos/_mapping/gram 
{ 
    "mappings": { 
    "gram": { 
     "properties": { 
     "gram": { 
      "type": "string", 
      "fields": { 
      "gram_bm25": { 
       "type": "string", "similarity": "BM25" 
      }, 
      "gram_lmd": { 
       "type": "string" 
      } 
      } 
     }, 
     "sentiment": { 
      "type": "string", "index": "not_analyzed" 
     }, 
     "word": { 
      "type": "string", "index": "not_analyzed" 
     } 
     } 
    } 
    } 
} 
  • 索引的名稱是「正」,我所說的類型'公克'。
  • 我已經創建了具有相同名稱的索引。
  • 我已經驗證使用http://jsonlint.com/
  • 我試圖在控制檯中使用XPUT和我得到了「aknowleged」響應的JSON,但映射仍然是{}當我感覺索取。
  • this問題沒有解決我的問題。我在任何地方都使用相同的名字。 有什麼建議嗎?

謝謝!

回答

1

您的API語法錯誤。基本上,你已經結合了兩種不同的方法。

無論是創建索引,然後應用映射:

DELETE /pos 

PUT /pos 

PUT /pos/gram/_mapping 
{ 
    "gram": { 
     "properties": { 
     "gram": { 
      "type": "string", 
      "fields": { 
       "gram_bm25": { 
        "type": "string", 
        "similarity": "BM25" 
       }, 
       "gram_lmd": { 
        "type": "string" 
       } 
      } 
     }, 
     "sentiment": { 
      "type": "string", 
      "index": "not_analyzed" 
     }, 
     "word": { 
      "type": "string", 
      "index": "not_analyzed" 
     } 
     } 
    } 
} 

或者做一次全部在創建索引:

DELETE /pos 

PUT /pos 
{ 
    "mappings": { 
     "gram": { 
     "properties": { 
      "gram": { 
       "type": "string", 
       "fields": { 
        "gram_bm25": { 
        "type": "string", 
        "similarity": "BM25" 
        }, 
        "gram_lmd": { 
        "type": "string" 
        } 
       } 
      }, 
      "sentiment": { 
       "type": "string", 
       "index": "not_analyzed" 
      }, 
      "word": { 
       "type": "string", 
       "index": "not_analyzed" 
      } 
     } 
     } 
    } 
} 

這是我使用的代碼:

http://sense.qbox.io/gist/6d645cc069f5f0fcf14f497809f7f79aff7de161

+0

啊,我明白了。非常感謝你,我得到它的工作! – Morgan

相關問題