查看全部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": "系統" } } ] } } }'