elasticsearch Elasticsearch-在过滤器中组合查询字符串和布尔查询
是否可以在elasticsearch Elasticsearch-在过滤器中组合查询字符串和布尔查询,elasticsearch,lucene,query-string,booleanquery,elasticsearch,Lucene,Query String,Booleanquery,是否可以在过滤器查询中组合查询\u字符串和布尔查询 例如— { "filter": { "query_string": { "query": "field:text" } }, "bool": { "should": { "match": { "field": "text" } } } } bool用于将各种查询合并到一个bool查询中。 您可以使用bool以这种方式组合多个查询- { "q
过滤器查询
中组合查询\u字符串
和布尔查询
例如—
{
"filter": {
"query_string": {
"query": "field:text"
}
},
"bool": {
"should": {
"match": {
"field": "text"
}
}
}
}
bool用于将各种查询合并到一个bool查询中。 您可以使用bool以这种方式组合多个查询-
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "field:text"
}
},
{
"match": {
"field": "text"
}
}
]
}
}
}
必须条款将确保所有条件都匹配。
您还可以使用should,它将确保在仅使用should的情况下匹配查询中的任何一个
由于bool只是另一种查询类型,您还可以在bool查询中加入bool查询,如下所示-
{
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"query_string": {
"query": "field:text"
}
},
{
"match": {
"field": "value"
}
}
]
}
},
{
"match": {
"field": "text"
}
}
]
}
}
}
我们如何瞄准多个领域?