精确匹配
使用term
可以实现精确匹配
查询title为 Beautiful Mind 的电影
GET movies/_search
{
"query": {
"term": {
"title": {
"value": "Beautiful Mind"
}
}
}
}
多条件或者判断
bool
must
条件同时成立should
条件满足单一即可
查询出title或者genre中包含romance,并且年份在2010到2020的电影
GET movies/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "romance",
"fields": ["title","genre"]
}
},
{
"range": {
"year": {
"gte": 2010,
"lte": 2020
}
}
}
]
}
}
}
查询出title或者genre中包含romance,或者年份在2010到2020的电影
GET movies/_search
{
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "romance",
"fields": ["title","genre"]
}
},
{
"range": {
"year": {
"gte": 2010,
"lte": 2020
}
}
}
]
}
}
}
本文由 guoxiaorui 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Aug 28, 2020 at 11:49 pm