This topic describes how to use Alibaba Cloud Elasticsearch (ES) to retrieve documents.

Use the Kibana console to access Alibaba Cloud Elasticsearch, and send the following request to retrieve documents:
  • Retrieve documents by index, type, and document ID.
    GET /my_index/my_type/1
    If the request is successful, the following result is returned:
    {
      "_index" : "my_index",
      "_type" : "my_type",
      "_id" : "1",
      "_version" : 3,
      "_seq_no" : 2,
      "_primary_term" : 1,
      "found" : true,
      "_source" : {
        "title" : "One World",
        "tags" : [
          "ruby"
        ],
        "post_date" : "2009-11-15T13:00:00"
      }
    }
  • Retrieve documents by index and type.
    GET /my_index/my_type/_search
    If the request is successful, the following result is returned:
    {
      "took" : 11,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 3,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "2",
            "_score" : 1.0,
            "_source" : {
              "title" : "Two",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T14:00:00"
            }
          },
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "title" : "One World",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T13:00:00"
            }
          },
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "3",
            "_score" : 1.0,
            "_source" : {
              "title" : "Three",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T15:00:00"
            }
          }
        ]
      }
    }
  • Retrieve documents by index.
    GET /my_index/_search
    If the request is successful, the following result is returned:
    {
      "took" : 44,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 3,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "2",
            "_score" : 1.0,
            "_source" : {
              "title" : "Two",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T14:00:00"
            }
          },
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "title" : "One World",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T13:00:00"
            }
          },
          {
            "_index" : "my_index",
            "_type" : "my_type",
            "_id" : "3",
            "_score" : 1.0,
            "_source" : {
              "title" : "Three",
              "tags" : [
                "ruby"
              ],
              "post_date" : "2009-11-15T15:00:00"
            }
          }
        ]
      }
    }