elasticsearch - List all documents in a index in elastic search - elastic - elastic search - elasticsearch tutorial - elasticsearch docker



Documents

  • Documents are JSON objects that are stored within an Elasticsearch index and are considered the base unit of storage.
  • In a relational database, documents can be compared to a row in table.
  • For example, if you are running an e-commerce application. You could have one document per product or one document per order. There is no limit to how many documents you can store in a particular index.
  • Data in documents is defined with fields comprised of keys and values. A key is the name of the field, and a value can be an item of several types such as a string, a number, a Boolean expression, another object, or an array of values.
  • Additionally, Documents contain reserved fields that establish the document metadata such as:
    • _index - The index where the document exists in.
    • _type - The type that the document denotes.
    • _id - The unique identifier for the document.

elasticsearch(ES) supports both a GET or a POST request for getting the data from the ES cluster index.

GET Method:

http://localhost:9200/[your index name]/_search?size=[no of records you want]&q=*:*

POST Method:

http://localhost:9200/[your_index_name]/_search
{
  "size": [your value] //default 10
  "from": [your start index] //default 0
  "query":
   {
    "match_all": {}
   }
}   

Here is a code to list all the documents in a index in elastic search.

curl -XGET http://www.example.com:9200/myIndexName/_search?pretty=true&q=*:*
  • It uses the Search API and will return all the entries under index myIndexName.

Related Searches to list all documents in a index in elastic search