Learn to build a search engine with node. JS and Elasticsearch (iii)

Source: Internet
Author: User

Using Elasticsearch to mention the Curl tool,Curl is an open source file Transfer tool that works with URL syntax in the command line mode. Website address:https://curl.haxx.se/

Because Elasticsearch provides a standard HTTP interface, we can use curl to easily access the Elasticsearch.

Some of the following collections use the Curl command to manipulate Elasticsearch.

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 all the _cat series operations

$Curl-xget Localhost:9200/_cat=^.^=/_cat/allocation/_cat/Shards/_cat/shards/{index}/_cat/Master/_cat/nodes/_cat/Tasks/_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/thread_pool/{thread_pools}/_cat/Plugins/_cat/Fielddata/_cat/fielddata/{fields}/_cat/Nodeattrs/_cat/repositories/_cat/snapshots/{repository}/_cat/templates

Second: _cluster series
1. Query Set cluster status

Curl-xget localhost:9200/_cluster/health?pretty=true  Pretty=true indicates formatted outputlevel =  Indices indicates display index statuslevel =shards indicates display shard information

2. Display cluster system information, including CPU, JVM, etc.

Curl-xget localhost:9200/_cluster/stats?pretty=True

3, display the details of the cluster, including nodes, shards and so on.

Curl-xget localhost:9200/_cluster/state?pretty=True

4, get the task of cluster accumulation.

Curl-xget localhost:9200/_cluster/pending_tasks?pretty=True

5. 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
6, manual control of the Shard

Curl-xpost ' Localhost:9200/_cluster/reroute '-d ' xxxxxx '

Reference http://zhaoyanblog.com/archives/687.html
7. Close the node
For example: 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 the master 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. Querying the state of a 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‘

IV: Index Operations
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. Delete 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 ":" Long "      },      " 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,    ' http:< c9>//localhost:9200/{index}/{type}/_search '-d ' {    "filter": {"and": {"Filters": [{"term": {" ":" 123 "}},{" term ": {" name ":" Zhang San "}}]},    " sort ": [{' age ': {" order ":" ASC "}},{" name ":" desc " }],
    "from": 0,    "size":

Reference original link address:http://zhaoyanblog.com/archives/732.html

Learn to build a search engine with node. JS and Elasticsearch (iii)

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.