现在es里有四个字段,分别是title,content,author,type,现在想指定type和keyword,在指定的type里搜索keyword,在官方文档里找了关天也没有找到相应的例子,网上找了下,由于这个比较难描述,也没有什么相符合的。
无意间看到must可以嵌套,这就好搞了。query DSL写法如下:
GET /_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "集团",
"fields": ["title","content","author"]
}
},
{
"bool": {
"must": [
{
"match": {
"type": "专题"
}
}
]
}
}
]
}
}
}