elasticSearch多条件高级检索语句,包含多个mustmust_notshould嵌套示例,并考虑nested对象的特殊检索
Posted 近朱朱者赤
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticSearch多条件高级检索语句,包含多个mustmust_notshould嵌套示例,并考虑nested对象的特殊检索相关的知识,希望对你有一定的参考价值。
多条件高级检索模板
多条件高级检索es语句,包含多个must、must_not、should嵌套示例,并考虑nested对象的特殊检索
该模板适用于所有情况,尤其适用于侧边栏多级多条件联合查询
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "Science"
}
},
{
"match": {
"countryArea": "United States"
}
},
{
"bool": {
"should": [
{
"match": {
"sponsor": "National Science Foundation"
}
},
{
"match": {
"sponsor": "David and Lucile Packard Foundation"
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": {
"nested": {
"path": "researchAreas",
"query": {
"bool": {
"should": [
{
"match": {
"researchAreas.subjectName": "Arts and Humanities"
}
},
{
"match": {
"researchAreas.subjectName": "Ecology"
}
}
],
"minimum_should_match": 1
}
}
}
}
}
}
],
"must_not": {
"match": {
"fundingType": "Program or Curriculum Development or Provision"
}
}
}
}
}
以上是关于elasticSearch多条件高级检索语句,包含多个mustmust_notshould嵌套示例,并考虑nested对象的特殊检索的主要内容,如果未能解决你的问题,请参考以下文章
14套java精品高级架构课,缓存架构,深入Jvm虚拟机,全文检索Elasticsearch视频教程