过滤器查询可以在过滤器索引中引用其他存储的查询文档吗?例如,假设我有以下 bool(boolean) 查询,其_id=1
已在渗滤器中建立索引:
{
"query": {
"bool": {
"must": [
{ "term": { "tag": "wow" } }
]
}
}
}
我可以用
_id=2
索引另一个查询吗(请注意,我正在组成_percolator_ref_id
术语查询关键字):{
"query": {
"bool": {
"should": [
{ "term": { "tag": "elasticsearch" } },
{ "terms" : { "_percolator_ref_id": [1] } }
]
}
}
}
如果我渗入以下文件:
{ "tag": "wow" }
我希望
_id=1
和_id=2
查询都可以匹配。是否存在诸如_percolator_ref_id
之类的功能?谢谢!
编辑:为了澄清起见,我不预先知道在给定查询中会出现多少个查询引用(例如
_id=2
查询可能会引用其他10个查询)。
最佳答案
您可以执行以下操作
以下索引中注册了2个查询
PUT myindex
{
"mappings": {
"properties": {
"query1": {
"type": "percolator"
},
"query": {
"type": "percolator"
},
"field": {
"type": "text"
}
}
}
}
您可以使用 bool(boolean) 值,必须/应该组合不同的查询
GET /myindex/_search
{
"query": {
"bool": {
"must": [
{
"percolate": {
"field": "query",
"document": {
"field": "fox jumps over the lazy dog"
}
}
},
{
"percolate": {
"field": "query1",
"document": {
"field": "fox jumps over the lazy dog"
}
}
}
]
}
}
}
关于elasticsearch - 您可以在Elasticsearch过滤器中引用其他查询吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58122968/