- Elasticsearch 知识点
| 功能 | curl命令 |
|---|---|
| 运行 Elasticsearch | ./bin/elasticsearch |
| 查看mapping(index是blog,type是java,使用get请求) | http://localhost:9200/blog/_mapping/java |
| 查看当前节点的所有 Index | curl -X GET 'http://localhost:9200/_cat/indices?v' |
| 新建 Index | curl -X PUT 'localhost:9200/weather' |
| 删除 Index | curl -X DELETE 'localhost:9200/weather' |
| 新增或更新记录 | 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' |
| 返回所有记录 | curl 'localhost:9200/accounts/person/_search' |
| match查询(from字段,指定位移;size字段,指定返回结果条数,默认10条) | curl 'localhost:9200/accounts/person/_search' -d '{"query" : { "match" : { "desc" : "管理" }}", "from": 1, "size": 20}' |
| 如果有多个搜索关键字, Elastic 认为它们是or关系。 此条命令搜索的是软件 or 系统。 | curl 'localhost:9200/accounts/person/_search' -d '{ "query" : { "match" : { "desc" : "软件 系统" }}}' |
| 执行多个关键词的and搜索,必须使用布尔查询 | `curl 'localhost:9200/accounts/person/_search' -d ' |
{
"query": {
"bool": {
"must": [
{ "match": { "desc": "软件" } },
{ "match": { "desc": "系统" } }
]
}
}
}'`