支持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": "我爱北京天安门" }