gpt4 book ai didi

elasticsearch - 您可以在Elasticsearch过滤器中引用其他查询吗?

转载 作者:行者123 更新时间:2023-12-02 23:13:15 26 4
gpt4 key购买 nike

过滤器查询可以在过滤器索引中引用其他存储的查询文档吗?例如,假设我有以下 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com