To manipulate Elasticsearch using the Curl command

Source: Internet
Author: User

To manipulate Elasticsearch using the Curl commandGreat Rock can't be published on April 25, 2015 Browse 7,426 times

First: _cat series
The _cat series provides a series of interfaces that query the state of the Elasticsearch cluster. You can do this by executing
Curl-xget Localhost:9200/_cat
Get the operation of all _cat series
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
You can also add a V to the output table to display the table header, for example

 name Component version type Urlprometheus analysis-mmseg NA jprometheus analysis-pinyin na  Jprometheus analysis-ik na jprometheus analysis-ik na jprometheus analysis-smartcn 2.1.0 jprometheus Segmentspy na s/_plugin/segmentspy/prometheus head na/_plugin/head/prometheus bigde      SK na s/_plugin/bigdesk/xandu analysis-ik na jxandu analysis-pinyin na jxandu Analysis-mmseg na jxandu analysis-smartcn 2.1.0 jxandu head na s/_plugin/head   /xandu Bigdesk na s/_plugin/bigdesk/onyxx analysis-ik na jonyxx analysis-mmseg     Na jonyxx analysis-smartcn 2.1.0 jonyxx analysis-pinyin na jonyxx head na s /_plugin/head/onyxx Bigdesk NA s/_plugin/bigdesk/

Second: _cluster series
1. Query Set cluster status
Curl-xget Localhost:9200/_cluster/health?pretty=true
Pretty=true representing formatted output
Level=indices indicates the index status is displayed
Level=shards indicates that shard information is displayed
2, Curl-xget Localhost:9200/_cluster/stats?pretty=true
Displays cluster system information, including CPU JVM, etc.
3, Curl-xget Localhost:9200/_cluster/state?pretty=true
Details about the cluster. Include nodes, shards, and so on.
3, Curl-xget Localhost:9200/_cluster/pending_tasks?pretty=true
Get cluster-stacked tasks
3. Modify the cluster configuration
Example:

Curl-xput localhost:9200/_cluster/settings-d ' {"    persistent": {        "discovery.zen.minimum_master_nodes": 2    }} '

Transient represents a temporary, persistent represents a permanent
4, curl-xpost ' Localhost:9200/_cluster/reroute '-d ' xxxxxx '
Manual control of Shard, Refer to http://zhaoyanblog.com/archives/687.html
5, close node
to close the specified 192.168.1.1 Node
Curl-xpost '/http 192.168.1.1:9200/_cluster/nodes/_local/_shutdown '
Curl-xpost ' http://localhost:9200/_cluster/nodes/ 192.168.1.1/_shutdown '
Close primary node
Curl-xpost ' Http://localhost:9200/_cluster/nodes/_master/_shutdown '
Close the entire cluster
$ Curl-xpost ' http://localhost:9200/_shutdown?delay=10s '
$ Curl-xpost ' Http://localhost:9200/_cluster /nodes/_shutdown '
$ Curl-xpost ' http://localhost:9200/_cluster/nodes/_all/_shutdown '
delay=10s indicates a delay of 10 seconds off

Third: _nodes series
1, status of the query node
curl-xget ' Http://localhost:9200/_nodes/stats?pretty=true '
Curl-xget ' http://localhost:9200/_nodes/192.168.1.2/stats?pretty=true '
Curl-xget ' http://localhost:9200/_ Nodes/process '
curl-xget ' http://localhost:9200/_nodes/_all/process '
Curl-xget ' http://localhost:9200/_ Nodes/192.168.1.2,192.168.1.3/jvm,process '
Curl-xget ' http://localhost:9200/_nodes/192.168.1.2,192.168.1.3/ Info/jvm,process '
Curl-xget ' http://localhost:9200/_nodes/192.168.1.2,192.168.1.3/_all
Curl-xget '/http Localhost:9200/_nodes/hot_threads

Fourth: index operation

1, get index
Curl-xget ' http://localhost:9200 /{index}/{type}/{id} '
2, index data
curl-xpost ' Http://localhost:9200/{index}/{type}/{id} '-d ' {"A": "Avalue", "B": " Bvalue "} '
3, DROP index
curl-xdelete ' Http://localhost:9200/{index}/{type}/{id} '
4, set mapping

Curl-xput http://localhost:9200/{index}/{type}/_mapping-d ' {"  {type} ': {" Properties ": {"  date ": {" type ":" Lo Ng "  },  " name ": {" type ":" string "," index ":" Not_analyzed "  },  " status ": {" type ":" Integer "  },  "type": {"type": "Integer"  }}}  '

5. Get mapping
Curl-xget http://localhost:9200/{index}/{type}/_mapping
6. Search

Curl-xget ' Http://localhost:9200/{index}/{type}/_search '-d ' {    "query": {"term        ": {"user": "Kimchy"}//Check all "Match_all": {}    }, "sort": [{"Age": {"Order": "ASC"}},{"name": "Desc"}], "from": 0, "size": 100}curl-xget ' http: Localhost:9200/{index}/{type}/_search '-d ' {    "filter": {"and": {"Filters": [{"term": {"age": "123"}},{"term": { "Name": "Zhang San"}]}, "sort": [{"Age": {"Order": "ASC"}},{"name": "Desc"}], "from": 0, "size": 100}

To manipulate Elasticsearch using the Curl command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.