2015-04-03 37 views
2

我正在使用elasticsearch 1.5.0。爲什麼在Elasticsearch中創建索引時這個新映射不起作用?

我以下面的方式創建一個新的索引,並將一些推文下載到新的索引中,但是當我查看實際的映射時,它並未使用此映射,但似乎試圖找出映射本身。我在這裏做錯了什麼?

curl -XPUT 'http://localhost:9200/tweets' -d ' 
{ 
    "tweets" : { 
    "mappings" : { 
     "tweet" : { 
     "properties" : { 
      "created_at" : { 
      "type" : "date", 
      "format" : "yyyy-MM-dd HH:mm:ss" 
      }, 
      "day" : { 
      "type" : "integer" 
      }, 
      "favorite_count" : { 
      "type" : "integer" 
      }, 
      "hashtags" : { 
      "properties" : { 
       "indices" : { 
       "type" : "integer" 
      }, 
      "text" : { 
      "type" : "string", 
      "index" : "analyzed", 
      "analyzer" : "standard" 
      } 
     } 
     }, 
     "id_str" : { 
      "type" : "long" 
     }, 
     "in_reply_to_screen_name" : { 
      "type" : "string", 
      "index" : "not_analyzed" 
     }, 
     "month" : { 
      "type" : "integer" 
     }, 
     "screen_name" : { 
      "type" : "string", 
      "index" : "not_analyzed" 
     }, 
     "text" : { 
      "type" : "string", 
      "index" : "analyzed", 
      "analyzer" : "standard" 
     }, 
     "urls" : { 
      "properties" : { 
      "display_url" : { 
       "type" : "string" 
      }, 
      "expanded_url" : { 
       "type" : "string", 
       "index" : "not_analyzed" 
      }, 
      "indices" : { 
       "type" : "long" 
      }, 
      "url" : { 
       "type" : "string", 
       "index" : "not_analyzed" 
      } 
      } 
     }, 
     "user_mentions" : { 
      "properties" : { 
      "id" : { 
       "type" : "long" 
      }, 
      "id_str" : { 
       "type" : "long" 
      }, 
      "indices" : { 
       "type" : "long" 
      }, 
      "name" : { 
       "type" : "string", 
       "index" : "not_analyzed" 
      }, 
      "screen_name" : { 
       "type" : "string", 
       "index" : "not_analayzed" 
      } 
      } 
     }, 
     "year" : { 
      "type" : "integer" 
     } 
     } 
     } 
    } 
    } 
}' 

當我測試了一些微博下載到索引和查詢映射我得到:

curl -XGET 'localhost:9200/tweets/_mapping/tweet?pretty' 

{ 
"tweets" : { 
    "mappings" : { 
    "tweet" : { 
     "properties" : { 
     "created_at" : { 
      "type" : "string" 
     }, 
     "day" : { 
      "type" : "string" 
     }, 
     "favorite_count" : { 
      "type" : "long" 
     }, 
     "hashtags" : { 
      "properties" : { 
      "indices" : { 
       "type" : "long" 
      }, 
      "text" : { 
       "type" : "string" 
      } 
      } 
     }, 
     "id_str" : { 
      "type" : "string" 
     }, 
     "in_reply_to_screen_name" : { 
      "type" : "string" 
     }, 
     "month" : { 
      "type" : "string" 
     }, 
     "screen_name" : { 
      "type" : "string" 
     }, 
     "text" : { 
      "type" : "string" 
     }, 
     "urls" : { 
      "properties" : { 
      "display_url" : { 
       "type" : "string" 
      }, 
      "expanded_url" : { 
       "type" : "string" 
      }, 
      "indices" : { 
       "type" : "long" 
      }, 
      "url" : { 
       "type" : "string" 
      } 
      } 
     }, 
     "user_mentions" : { 
      "properties" : { 
      "id" : { 
       "type" : "long" 
      }, 
      "id_str" : { 
       "type" : "string" 
      }, 
      "indices" : { 
       "type" : "long" 
      }, 
      "name" : { 
       "type" : "string" 
      }, 
      "screen_name" : { 
       "type" : "string" 
      } 
      } 
     }, 
     "year" : { 
      "type" : "string" 
     } 
     } 
    } 
    } 
} 
} 

當我檢查映射索引鳴叫我得到以下結果,我之前指數任何推文到它:

curl -XGET 'localhost:9200/tweets/_mapping?pretty' 
{ 
    "tweets" : { 
    "mappings" : { } 
    } 
} 
+0

您是否在發佈此信息後立即詢問映射並發現其不同?返回的映射是什麼樣的? – GlenRSmith 2015-04-03 12:21:34

+0

我已經通過測試後得到的響應更新了該問題,以便將一些推文下載到索引中。 – mattiasostmar 2015-04-03 16:22:42

+0

這將包括動態映射。發佈索引創建後,立即映射是什麼? – GlenRSmith 2015-04-03 18:38:17

回答

0

你可能注意到你的帖子試圖創建索引返回的錯誤?在「screen_name」下你有「not_analayzed」。將其改爲「not_analyzed」,你會沒事的。

相關問題