elasticsearch 命令行curl操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zgahlibin/article/details/78436494

命令行curl操作。

curl操作有四种类型

# curl -X GET 'http://host:port'                 

-X GET 可以省略


# curl -X POST


# curl -X PUT 

# curl -X DELETE


curl look for elasticsearch info
$ curl -X GET 'http://localhost:9200'


view all indices
$ curl -X GET 'http://localhost:9200/_cat/indices?v'


create index   index name  'weather'
$ curl -X PUT 'http://localhost:9200/weather2'




delete index  index name 'weather'
$ curl -X DELETE 




create index  with type and mapping
index accounts   
type persion    
mapping  properties's  attribute
$ 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"
        }
      }
    }
  }
}'



view mappings
$ curl -X GET 'localhost:9200/_mapping?pretty=true'


insert data
$ curl -X POST 'localhost:9200/accounts/person' -d '
{
  "user": "李四",
  "title": "工程师",
  "desc": "系统管理"
}'



search all accrods
$ curl 'http://localhost:9200/accounts/person/_search?pretty=true'




$ curl 'localhost:9200/accounts/person/_search'  -d '
{
  "query" : { "match" : { "desc" : "软件" }}
}'



猜你喜欢

转载自blog.csdn.net/zgahlibin/article/details/78436494