基本匹配:
{
"query":{
"match":{
"title" : "quick"
}
}
}
ES语法结构:
bool <-AND- must, must not, should
should <-OR- bool
OR语句:
{
"query":{
"match":{
"title" : "brown dog"
}
}
}
等价于
{
"query":{
"bool":{
"should":[
{
"term":{
"title":"brown"
}
},{
"term":{
"title":"dog"
}
}
]
}
}
}
AND语句:
{
"query":{
"match":{
"title":{
"query":"brown dog",
"operator":"and"
}
}
}
}
等价于
{
"query":{
"bool":{
"must":[
{
"term":{
"title":"brown"
}
},{
"term":{
"title":"dog"
}
}
]
}
}
}
复合语句
1)
{
"query":{
"bool":{
"must":{
"match":{
"title":"quick"
}
},
"should":[
{
"match":{
"title":"brown"
}
},{
"match":{
"title":"dog"
}
}
]
}
}
}
2)
{
"query":{
"bool":{
"must":{
"match":{
"content":{
"query":"full text search",
"operator":"and"
}
}
},
"should":[
{
"match":{
"content":"elastic search"
}
},{
"match":{
"content":"lucene"
}
}
]
}
}
}