ElasticSearch (1) REST API -- ES server itself

http://www.elasticsearch.org/

http://elasticsearch-users.115913.n3.nabble.com/

https://groups.google.com/forum/?fromgroups=#!forum/elasticsearch

##### index settings ##### 

http://ES_HOST_SERVER:9200/INDEX_NAME/_settings

#####  pretty format ##### 

http://ES_HOST_SERVER:9200/153299/_settings?pretty=true

#####  index status ##### 

http://ES_HOST_SERVER:9200/153299/_status?pretty=true

#####  cluster settings ##### 

http://ES_HOST_SERVER:9200/_cluster/settings?pretty=true

#####  Cluster Health ##### 

http://ES_HOST_SERVER:9200/_cluster/health?pretty=true

#####  cluster state ##### 

http://ES_HOST_SERVER:9200/_cluster/state?pretty=true

#####  Cluster Update Settings ##### 

curl -XPUT ES_HOST_SERVEAR:9200/_cluster/settings -d '{

    "persistent" : {

        "discovery.zen.minimum_master_nodes" : 2

    }

}'

#####  Node info ##### 

http://ES_HOST_SERVER:9200/_cluster/nodes?pretty=true

#####  local node info ##### 

http://ES_HOST_SERVER:9200/_cluster/nodes/_local

##### node address ##### 

http://ES_HOST_SERVER:9200/_cluster/nodes/10.49.216.121

#####  node name ##### 

http://ES_HOST_SERVER:9200/_cluster/nodes/Eternity

#####  Nodes Shutdown ##### 

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/_local/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/nodeId1,nodeId2/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/_master/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/_all/_shutdown'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cluster/nodes/_local/_shutdown?delay=10s'

The shutdown API can be disabled by setting action.disable_shutdown in the node configuration.

#####  Nodes restart ##### 

curl -XPOST 'http://0.42.108.201:9200/_cluster/nodes/_restart'

Node can be restated only if the wrapper service is setup.

##### Cluster Nodes hot_threads ##### 

http://ES_HOST_SERVER:9200/_nodes/hot_threads?pretty=true

#####  mapping ##### 

#####  get index mapping ##### 

http://ES_HOST_SERVER:9200/153299/_mapping

host:port/{index}/{type}/_mapping

where both {index} and {type} can stand for comma-separated list of names. To get mappings for all indices you can use _all for {index}. The following are some examples:

http://ES_HOST_SERVEAR:9200/INDEX_NAME,kimchy/_mapping

http://ES_HOST_SERVEAR:9200/_all/tweet,book/_mapping

http://ES_HOST_SERVER:9200/_all/_mapping

http://ES_HOST_SERVER:9200/_mapping

#####  optimize ##### 

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/kimchy,elasticsearch/_optimize'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_optimize'

#####  flush index ##### 

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/kimchy,elasticsearch/_flush'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_flush'

#####  Gateway Snapshot  ##### 

Note, this API only applies when using shared storage gateway implementation, 

and does not apply when using the (default) local gateway

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/kimchy,elasticsearch/_gateway/snapshot'

$ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_gateway/snapshot'

#####  Indices Update Settings ##### 

#####  Indices Stats ##### 

http://ES_HOST_SERVER:9200/_stats?pretty=true

By default, docs, store, and indexing, get, and search stats are returned, other stats can be enabled as well:

docs: The number of docs / deleted docs (docs not yet merged out). Note, affected by refreshing the index.

store: The size of the index.

indexing: Indexing statistics, can be combined with a comma separated list of types to provide document type level stats.

get: Get statistics, including missing stats.

search: Search statistics, including custom grouping using the groups parameter (search operations can be associated with one or more groups).

merge: merge stats.

flush: flush stats.

refresh: refresh stats.

clear: Clears all the flags (first).

Here are some samples:

# Get back stats for merge and refresh on top of the defaults

curl 'ES_HOST_SERVEAR:9200/_stats?merge=true&refresh=true'

# Get back stats just for flush

curl 'ES_HOST_SERVEAR:9200/_stats?clear=true&flush=true'

# Get back stats for type1 and type2 documents for the my_index index

curl 'ES_HOST_SERVEAR:9200/my_index/_stats?clear=true&indexing=true&types=type1,type2

#####  Translog ##### 

Each shard has a transaction log or write ahead log associated with it. It allows to guarantee that when an index/delete operation occurs, it is applied atomically, while not “committing” the internal lucene index for each request. A flush (“commit”) still happens based on several parameters:

SettingDescription

index.translog.flush_threshold_opsAfter how many operations to flush. Defaults to 5000.

index.translog.flush_threshold_sizeOnce the translog hits this size, a flush will happen. Defaults to 500mb.

index.translog.flush_threshold_periodThe period with no flush happening to force a flush. Defaults to 60m.

 #####  Indices Segments ##### 

curl -XGET 'http://ES_HOST_SERVEAR:9200/INDEX_NAME/_segments'

curl -XGET 'http://ES_HOST_SERVEAR:9200/INDEX_NAME1,INDEX_NAME2/_segments'

curl -XGET 'http://ES_HOST_SERVER:9200/_segments?pretty=true'

 #####  clear catche ##### 

 $ curl -XPOST 'http://ES_HOST_SERVEAR:9200/INDEX_NAME/_cache/clear'

 $ curl -XPOST 'http://ES_HOST_SERVEAR:9200/INDEX_NAME1,INDEX_NAME2/_cache/clear'

 $ curl -XPOST 'http://ES_HOST_SERVEAR:9200/_cache/clear'

 The API, by default, will clear all cached. Specific caches can be cleaned explicitly by setting filter, field_data or bloom to true.

 #####  Indices Exists ##### 

curl -XHEAD 'http://ES_HOST_SERVEAR:9200/INDEX_NAME'

 #####  Types Exists ##### 

curl -XHEAD 'http://ES_HOST_SERVEAR:9200/INDEX_NAME/INDEX_TYPE'

猜你喜欢

转载自ilnba.iteye.com/blog/1725610