美文网首页
Elasticsearch REST API使用

Elasticsearch REST API使用

作者: endlesswork | 来源:发表于2021-05-23 16:11 被阅读0次
语法 含义
http://127.0.0.1:9200/_search 查询所有索引
http://127.0.0.1:9200/index1/_search 查询index1索引上数据
http://127.0.0.1:9200/index1,index2/_search 查询index1和index2索引上数据
http://127.0.0.1:9200/index*/_search 查询index开头索引上数据
http://127.0.0.1:9200/*index/_search 查询index结尾索引上数据
http://127.0.0.1:9200/*index*/_search 查询包含index索引上数据

get 嵌套查询

在一些复杂的查询中,比如我们要查询name为tom的,样例如下

 get请求
http://127.0.0.1:9200/index1/_search

{
    "query":{
        "match": {
            "name": "tom"
        }
    }
}

结果如下

{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 0.2876821,
        "hits": [
            {
                "_index": "index1",
                "_type": "_doc",
                "_id": "aaaabbbb",
                "_score": 0.2876821,
                "_source": {
                    "@version": "1",                 
                    "name": "tom",
                    "info": {
                        "like": "swim"
                    }
                }
            }
        ]
    }
}

如果我们要查询info下面like为swim的 那么查询条件如下

 get请求
http://127.0.0.1:9200/index1/_search

{
    "query":{
        "match": {
            "info.like": "swim"
        }
    }
}

相关文章

网友评论

      本文标题:Elasticsearch REST API使用

      本文链接:https://www.haomeiwen.com/subject/lvdyjltx.html