Elasticsearch基本操作

Elasticsearch基本操作

curl -XGET http://127.0.0.1:9200/_cat/indices?v

curl -XPUT http://127.0.0.1:9200/indexxxx

curl -XGET http://127.0.0.1:9200/indexxxx

curl -H'Content-Type: application/json' -XPOST http://127.0.0.1:9200/indexxxx/_doc/1001 -d '
{
    "name":"hhhhh", 
    "sex":"man"
}'

curl -XGET 127.0.0.1:9200/indexxxx/_doc/1001

curl -XPOST -H 'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_update/1002 -d '
{ 
    "doc" : 
    { 
        "agee" : 25 
    } 
}'

curl -XDELETE 127.0.0.1:9200/indexxxx/_doc/1003

curl -H'Content-Type:application/json'  -XPOST 127.0.0.1:9200/indexxxx/_search  -d '
{ 
    "query" : 
    { 
        "match" : 
        { 
            "name" : "zhanggggg" 
        } 
    } 
} '
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "match_all":{}
    }
},
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "match_all":{}
    }, 
    "from":2, 
    "to":2,
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "match_all":{}
    }, 
    "from":2, 
    "to":2,
    "_source":["age"]
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "bool":
        {
            "must":
            [ 
                { 
                    "match":
                    {  
                        "age":22 
                    } 
                }, 
                {
                    "match":
                    {
                        "name":"huaiiiii"
                    } 
                }
            ]
        }
    }
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "bool":
        {
            "should":
            [
                {
                    "match":
                    {
                        "name":"leeeee"
                    }
                }, 
                {
                    "match":
                    {
                        "age":22
                    }
                }
            ]
        }
    }
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "bool":
        {
            "should":
            [
                {
                "match":
                    {
                        "name":"leeeee"
                    }
                },
                {
                    "match":
                    {
                        "age":22
                    }
                }
            ],
            "filter": 
            {
                "range":
                {
                    "age":
                    {
                        "gt":20
                    }
                }
            }
        }
    }
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query":
    {
        "bool" :
        {
            "must": 
            {
                "match_phrase":
                {
                    "name":"李"
                }
            }
        }
    }
}'
curl -XPOST -H'Content-Type:application/json' 127.0.0.1:9200/indexxxx/_search -d '
{
    "query": 
    {
        "bool" :
        {
            "must":
            {
                "match_phrase":
                {
                    "name":"李"
                }
            }
        }
    },
    "highlight":
    {
        "fields":
        {
            "name":{}
        }
    }
}' 
curl -XPOST -H"Content-Type:application/json" 127.0.0.1:9200/iiii/_search -d '
{
    "aggs":
    {
        "nnn_grp":
        {
            "terms":
            {
                "field":"num"
            }
        }
    }, 
    "size":0
}'
curl -XPOST -H"Content-Type:application/json" 127.0.0.1:9200/iiii/_search -d '
{
    "aggs":
    {
        "nnn_grp":
        {
            "agv":
            {
                "field":"num"
            }
        }
    }, 
    "size":0
}'
curl -k --user "name:passwd" https://xx.xx.xx.xx:9200
curl -XPOST -H"Content-Type:application/json" 127.0.0.1:9200/iiii/_search -d '
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "key11.key12.field1": {
              "gte": "20240517000000",
              "lte": "20240517235959"
            }
          }
        },
        {
          "term": {
            "key21.field2": "xxxxxxxx"
          }
        },
        {
          "term": {
            "key31.key32.field3" : "yyyyyyyyyyy"
          }
        },
        {
          "query_string": {
            "fields": [
              "key41.key42.field4"
            ],
            "query": "(/.*zzzzzzz.*/)"
          }
        }
      ]
    }
  },
  "track_total_hits": true,
  "from": 0,
  "size": 10
}'

curl -XGET http://127.0.0.1:9200/indexxxx/_mapping

curl -XGET http://127.0.0.1:9200/indexxxx/_count

curl -XGET http://127.0.0.1:9200/_cat/nodes

curl -XGET http://127.0.0.1:9200/_nodes/stats

curl -XGET http://127.0.0.1:9200/_cat/shards?v

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注