【问题标题】:not in search query in elasticsearch不在elasticsearch中的搜索查询中
【发布时间】:2023-03-27 20:24:01
【问题描述】:

我想知道是否有使用 elasticsearch DSL 的搜索查询来查找所有值,除了满足数据库中 dateOptionalTime 字段的特定条件的值。

等效的SQL query 将是:

select * from index 
where (not (date="0001-01-01T00:00:00+03:30")) 
and (domain="somthing.com");

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    是的,您可以使用bool/must_not 来实现:

    {
      "query": {
        "bool": {
          "filter": {
            "term": {
              "domain": "something.com"
            }
          },
          "must_not": {
            "term": {
              "date": "0001-01-01T00:00:00+03:30"
            }
          }
        }
      }
    }
    

    【讨论】:

    • 这个运气好吗?
    猜你喜欢
    • 2017-04-02
    • 2023-03-26
    • 2016-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    相关资源
    最近更新 更多