查看全部index数据库
curl -X GET 'localhost:9200/_cat/indices?v'
查看每一个index全部的typeapp
curl 'localhost:9200/_mapping?pretty=true'
新建indexcurl
curl -X PUT 'localhost:9200/weather'
删除indexurl
curl -X DELETE 'localhost:9200/weather'
新建index并指定要分词的字段(accounts是index,person是type,person有三个字段)code
curl -X PUT 'localhost:9200/accounts' -d ' { "mappings": { "person": { "properties": { "user": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" }, "title": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" }, "desc": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } } } } }'
index里新增documentit
curl -X PUT 'localhost:9200/accounts/person/1' -d ' { "user": "张三", "title": "工程师", "desc": "数据库管理" }'
查看记录软件
curl 'localhost:9200/accounts/person/1?pretty=true'
删除记录搜索
curl -X DELETE 'localhost:9200/accounts/person/1'
查看全部记录map
curl 'localhost:9200/accounts/person/_search'
查找(经过from和size指定位移,分页操做)分页
curl 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "管理" }}, "from": 1, "size": 1 }'
多个关键字搜索(or)
curl 'localhost:9200/accounts/person/_search' -d ' { "query" : { "match" : { "desc" : "管理" }}, "from": 1, "size": 1 }'
多个关键词搜索(and)
curl 'localhost:9200/accounts/person/_search' -d ' { "query": { "bool": { "must": [ { "match": { "desc": "软件" } }, { "match": { "desc": "系统" } } ] } } }'