查询结果解释
- took - 耗费多少毫秒
- time_out - 是否超时
- _shards - 数据分片情况
- hits.total - 查询结果的数量
- hits.max_score - document 对于一个 search 的相关度匹配分数,越相关分数越高
- hits.hits - 匹配 document 的详细数据
query string search
- 语法
GET /index/type/_search
查询全部商品
GET /ecommerce/product/_search
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 3,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "ecommerce",
"_type": "product",
"_id": "1",
"_score": 1,
"_source": {
"name": "gaolujie yagao",
"desc": "gaoxiao meibai",
"price": 30,
"producer": "gaolujie producer",
"tags": [
"meibai",
"fangzhu"
]
}
}
...
]
}
}
条件查询排序
查询商品名称中包含
yagao
的商品,而且按照售价降序排序
GET /ecommerce/product/_search?q=name:yagao&sort=price:desc
query DSL 【常用】
Domain Specified Language:特定领域的语言
- 语法
GET /index/type/_search