写在前面
项目中遇到了一个查询问题,原本查询是title=“A” or content=“B”,经需求优化,需要变成(title=“A” or content=“B”) and (state = “C”)。
原始需求
查询title或introduction中满足的字段值
GET forexknow_album_bean/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"title": {
"query": "妲",
"boost": 2
}
}},
{
"match": {
"introduction": {
"query": "熵"
}
}}
]
}
}
, "size": 20
}
查询结果为null:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5