This topic describes how to use Alibaba Cloud Elasticsearch to search for data. Elasticsearch supports two search methods: full-text search and search by condition.

Search by condition

Run the following command to search for products with an annualized rate of 3.0000% to 3.1300%.

GET /product_info/products/_search
{
  "query": {
    "range": {
      "annual_rate": {
        "gte": "3.0000%",
        "lte": "3.1300%"
      }
    }
  }
}

If the command is executed successfully, the following result is returned:

{
  "took" : 10,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "product_info",
        "_type" : "products",
        "_id" : "WLvWYXAB8Rql5AUxLqUU",
        "_score" : 1.0,
        "_source" : {
          "productName" : "Western Tongbao",
          "annual_rate" : "3.1100%",
          "describe" : "90-day wealth management product. Minimum investment of CNY 10,000. Daily push messages when returns are credited to your account."
        }
      },
      {
        "_index" : "product_info",
        "_type" : "products",
        "_id" : "WrvWYXAB8Rql5AUxLqUU",
        "_score" : 1.0,
        "_source" : {
          "productName" : "Monthly 5G Device Purchase Profit",
          "annual_rate" : "3.1200%",
          "describe" : "90-day wealth management product. Minimum investment of CNY 12,000. Daily push messages when returns are credited to your account."
        }
      }
    ]
  }
}

Elasticsearch finds products that meet requirements based on the search condition and displays the products in descending order.

For more information, see Query DSL.