标签:文档 desc author pre order 数据 should not 匹配
简单查询
mall/goods/1
条件查询
GET mall/goods/_search?q=b_name: "如何"
匹配查询
GET mall/goods/_search
{
"query": {
"match": {
"b_name": "怎样征服美丽少女"
}
}
}
查询的结果只展示指定的字段
GET mall/goods/_search
{
"query": {
"match": {
"b_name": "怎样征服美丽少女"
}
},
"_source": ["b_name","author"]
}
排序
GET mall/goods/_search
{
"query": {
"match": {
"b_name": "怎样征服美丽少女"
}
},
"_source": ["b_name","author","price"],
"sort": [
{
"price": {
"order": "desc"
}
}
]
}
分页
GET mall/goods/_search
{
"query": {
"match": {
"b_name": "怎样征服美丽少女"
}
},
"_source": ["b_name","author","price"],
"sort": [
{
"price": {
"order": "desc"
}
}
],
"from": 0,
"size": 2
}
布尔查询
bool:
must,should,must_not,filter
必须同时匹配多个条件查询,相当于and
GET mall/goods/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"b_name": "美丽少女"
}
},
{
"match": {
"price": "28"
}
}
]
}
}
}
只要符合多个条件中的一个条件,相当于or
GET mall/goods/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"b_name": "美丽少女"
}
},
{
"match": {
"price": "28"
}
}
]
}
}
}
非查询,not
GET mall/goods/_search
{
"query": {
"bool": {
"must_not": [
{
"match": {
"b_name": "美丽少女"
}
},
{
"match": {
"price": "23"
}
}
]
}
}
}``
过滤查询
gte:>=
lte:<=
GET mall/goods/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"b_name": "如何征服"
}
}
],
"filter": {
"range": {
"price": {
"gte": 10,
"lte": 40
}
}
}
}
}
}
快速模糊匹配查询(多个条件用空格隔开),相当于 or
GET mall/goods/_search
{
"query": {
"match": {
"b_name": "如何 骗"
}
},
"_source": ["b_name"]
}
标签:文档 desc author pre order 数据 should not 匹配
原文地址:https://www.cnblogs.com/wang-py/p/14916602.html