原文链接:ElasticSearch多种搜索方式

一、Query String Search(‘Query String’方式的搜索)

1.搜索全部商品

GET /shop_index/productInfo/_search

返回结果:

{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 1,
    "hits": [
      {
        "_index": "shop_index",
        "_type": "productInfo",
        "_id": "2",
        "_score": 1,
        "_source": {
          "test": "test"
        }
      },
      {
        "_index": "shop_index",
        "_type": "productInfo",
        "_id": "zyWpRGkB8mgaHjxk0Hfo",
        "_score": 1,
        "_source": {
          "name": "HuaWei P20",
          "desc": "Expen but easy to use",
          "price": 5300,
          "producer": "HuaWei Producer",
          "tags": [
            "Expen",
            "Fast"
          ]
        }
      },
      {
        "_index": "shop_index",
        "_type": "productInfo",
        "_id": "1",
        "_score": 1,
        "_source": {
          "name": "HuaWei Mate8",
          "desc": "Cheap and easy to use",
          "price": 2500,
          "producer": "HuaWei Producer",
          "tags": [
            "Cheap",
            "Fast"
          ]
        }
      }
    ]
  }
}
View Code

相关文章: