In this article, I will take you through 10 Best ElasticSearch API Query. Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java. Here we will see different types of Elasticsearch api query one can use to check the snapshot and indices details.
Ans. Below is the query to setup the number of shards and replicas.
curl -XPUT 'localhost:9200/index?pretty' -H 'Content-Type: application/json' -d '
{
"settings":{
"number_of_shards":2,
"number_of_replicas":1
}
}
'
Below is the query to get all the snapshot in a proper format.
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty"
Below is the query to check the total number of snapshots.
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | grep -i snapshot | wc -l
Below is the query to check the total number of indices.
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | grep -i indices | wc -l
Below is the query to get only the indices from every snapshots
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[].indices'
Below is the query to get 11th indices of every snapshots
curl -XGET "http://192.168.13.16:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[].indices[10]'
Below is the query to get only indices from first snapshot.
curl -XGET "http://192.168.13.16:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[0].indices[]'
Below is the query to get the first indice from every snapshot
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[].indices[0]'
Below is the query to get all indices from Second Snapshot.
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[1].indices[]'
Below is the query to get the second indices of every snapshots.
curl -XGET "localhost:9200/_snapshot/testrepo/_all?pretty" | jq -r '.snapshots[].indices[1]'
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!