【es】es curl命令行工具实用命令3

1.es通过curl 命令行工具实用命令3 

精确匹配查询
curl -u elastic:elastic -k -XGET 192.168.1.1:9200/pro_002/_search -H 'Content-Type: application/json' -d '
{
  "query": {
    "term": {
      "name": "pro_002"
    }
  }
}'
{
    "took":5,
    "timed_out":false,
    "_shards":{
        "total":1,
        "successful":1,
        "skipped":0,
        "failed":0
    },
    "hits":{
        "total":{
            "value":1,
            "relation":"eq"
        },
        "max_score":0.6931471,
        "hits":[
            {
                "_index":"pro_002",
                "_type":"_doc",
                "_id":"2",
                "_score":0.6931471,
                "_source":{
                    "id":"2",
                    "name":"pro_002",
                    "city":"广州",
                    "course":"oracle",
                    "teacher":"pro",
                    "pxdate":"20250311"
                }
            }
        ]
    }
}
27.范围查询
curl -u elastic:elastic -k -XGET 192.168.1.1:9200/pro_002/_search -H 'Content-Type: application/json' -d '
{
  "query": {
    "range": {
      "id": {
        "gte": 0,  
        "lte": 10  
      }
    }
  }
}'

{
    "took":1082,
    "timed_out":false,
    "_shards":{
        "total":1,
        "successful":1,
        "skipped":0,
        "failed":0
    },
    "hits":{
        "total":{
            "value":1,
            "relation":"eq"
        },
        "max_score":1,
        "hits":[
            {
                "_index":"pro_002",
                "_type":"_doc",
                "_id":"1",
                "_score":1,
                "_source":{
                    "id":"1",
                    "name":"user001",
                    "city":"广州",
                    "course":"oracle",
                    "teacher":"xsq1",
                    "pxdate":"20250306"
                }
            }
        ]
    }
}
28.must查询指定条件的索引
查询name='pro_002'的索引
curl -u elastic:elastic -k -XGET 192.168.1.1:9200/pro_002/_search  -H 'Content-Type: application/json' -d '
{
  "query": {
    "bool": {
      "must": [
        { "match": { "name": "pro_002" }}
      ]
    }
  }
}'
{
    "took":6,
    "timed_out":false,
    "_shards":{
        "total":1,
        "successful":1,
        "skipped":0,
        "failed":0
    },
    "hits":{
        "total":{
            "value":1,
            "relation":"eq"
        },
        "max_score":0.6931471,
        "hits":[
            {
                "_index":"pro_002",
                "_type":"_doc",
                "_id":"2",
                "_score":0.6931471,
                "_source":{
                    "id":"3",
                    "name":"pro_002",
                    "city":"深圳",
                    "course":"mysql",
                    "teacher":"粉缇",
                    "pxdate":"20250312"
                }
            }
        ]
    }
}

29.should 查询指定条件的记录
Name='pro_002' 或者 id=3
curl -u elastic:elastic -k -XGET 192.168.1.1:9200/pro_002/_search  -H 'Content-Type: application/json' -d '
{
  "query": {
    "bool": {
     "should": [
      { "match": { "name": "pro_002" }},
      { "match": { "id":"3"} }
     ],
      "minimum_should_match": 1 
    }
  }
}'
{
    "took":6,
    "timed_out":false,
    "_shards":{
        "total":1,
        "successful":1,
        "skipped":0,
        "failed":0
    },
    "hits":{
        "total":{
            "value":1,
            "relation":"eq"
        },
        "max_score":1.3862942,
        "hits":[
            {
                "_index":"pro_002",
                "_type":"_doc",
                "_id":"2",
                "_score":1.3862942,
                "_source":{
                    "id":"3",
                    "name":"pro_002",
                    "city":"深圳",
                    "course":"mysql",
                    "teacher":"粉缇",
                    "pxdate":"20250312"
                }
            }
        ]
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值