支持RESTful風格數據庫
PUT person #建立索引 GET person #獲取索引信息
PUT person/_mapping #建立映射 { "properties":{ "name":{ "type":"keyword" }, "age":{ "type":"integer" } } } GET person/_mapping 獲取映射信息
PUT student #建立索引的時候添加映射 { "mappings": { "properties": { "name":{ "type": "text" }, "age":{ "type": "integer" } } } }
PUT person/_mapping #添加映射 { "properties": { "address":{ "type": "text" } } }
PUT person/_doc/1 #指定id添加文檔 不指定id只能夠用post請求方式 { "name":"zhangsan", "age":20, "address":"beijing" }
GET person/_search #查詢全部 GET person/_search #刪除文檔
中文分詞器拷貝到ElasticSearch的plugins目錄app
重啓elastic searchelasticsearch
映射(mapping)時候字段的type爲"keyword"表示不分詞工具
映射(mapping)時候字段的type爲"text"表示分詞post
PUT student #建立索引的時候添加映射 { "mappings": { "properties": { "name":{ "type": "text" }, "address":{ "type": "text", #text類型爲分詞 須要指定分詞器 "analyzer":"ik_max_word" } } } }
ik_smart 粗粒度分詞方式調試
ik_max_word 細粒度分詞方式code
GET _analyze #分詞爲:我 愛 北京 天安門 { "analyzer": "ik_smart" , "text": "我愛北京天安門" } GET _analyze#分詞爲:我 愛 北京 天安門 天安 門 { "analyzer": "ik_max_word", "text": "我愛北京天安門" }