gpt4 book ai didi

elasticsearch - 如何在Elasticsearch中的多个字段上创建 bool 过滤器?

转载 作者:行者123 更新时间:2023-12-02 23:22:56 24 4
gpt4 key购买 nike

我在Elasticsearch中有以下查询:

{
"script_fields": {
"travel_time": {
"script": {
"inline": "doc['DateTo'].value - doc['DateFrom'].value"
}
}
},
"stored_fields": [
"_source"
],
"query": {
"bool": {
"filter": {
"exists": {
"field": "DateTo"
}
}
}
}
}

如何将 DateFrom添加到 exists过滤器?

最佳答案

您可以添加多个exists条件:

  "query": {
"bool": {
"filter": [
{
"exists": {
"field": "DateFrom"
}
},
{
"exists": {
"field": "DateTo"
}
},
{
"script": {
"script": {
"inline": "doc['DateTo'].value - doc['DateFrom'].value > 0"
}
}
}
]
}
}

关于elasticsearch - 如何在Elasticsearch中的多个字段上创建 bool 过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46832783/

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