This post will elaborate on:
- How to Get All Documents From the Index Using “curl” Command in Elasticsearch?
- How to Get All Documents From an Index in Kibana?
How to Get All Documents From an Index Using “curl” Command in Elasticsearch?
To access all the documents from Elasticsearch indexes, the “_search” queries can be used along with the “GET” API. For illustration, follow up on the below-mentioned instructions.
Step 1: Launch Elasticsearch Engine
First, navigate to the Elasticsearch “bin” folder:
Run the batch file “elasticsearch.bat” to start the engine on the system:
Elasticsearch will be started when the cluster health turns to “YELLOW” as shown below:
Step 2: Access Elasticsearch From CLI
Now, utilize the “curl” command to access data from the server. Here, we are accessing Elasticsearch data from the “localhost:9200”:
In the above command, “-u” is utilized to pass the “elastic” user credentials along with the command:
Step 3: Access All Documents From an Index
In order to access all the documents from a specific index, utilize the “_search” query in the “GET” API request:
In the above command:
- “GET” is an API that is utilized to access data from indexes.
- “linuxhint” is the name of the index where all documents are being extracted.
- “_search” is a query that is utilized to search all documents from an index:
The above output shows the data in a bulky form that is difficult to read. To make it readable, utilize the “?pretty” method as done below:
The below output indicates that we have successfully accessed all the documents from the “linuxhint” index:
Executing messy commands is challenging and the chances of errors are more. To avoid using massive commands, users can utilize Kibana.
How to Get All Documents From an Index in Kibana?
Kibana is an Elasticsearch visualization tool to represent data in visual form. It also offers a console from where users can run queries to store, retrieve and manage data in Elasticsearch indexes. In order to access all the documents from an index, follow the listed instructions.
Step 1: Start Kibana
First, start the Kibana. To do so, first, open its “bin” directory through the “cd” command:
Then, run the Kibana’s batch file “kibana.bat” to start it on the system:
Step 2: Sign In to Kibana
After Kibana is properly started, navigate to its default URL “localhost:5601” provide the “elastic” user credentials, and hit the “Log in” button:
Step 3: Open Kibana Console
Open the Kibana menu by hitting the “Triple bar” icon. After that, open the “Dev Tools” to launch the Kibana console:
Step 4: Access All Documents From Index
In order to access all documents from the index, simply use the “GET /<indexname>/_search” API request:
The output indicates that we have successfully accessed the documents from an index using the Kibana console:
That is all about retrieving all documents from the index in Elasticsearch.
Conclusion
To retrieve all the Documents from an index in Elasticsearch, users can either use the “curl” command along with the “GET” API request or use the Kibana console. Elasticsearch documents are retrieved by using the “_search” query with “GET” API such as the “Get /<index-name>/_search” request. This post has illustrated the methods to access all the documents from an index in Elasticsearch.