zoukankan      html  css  js  c++  java
  • 范围查询 range query

    范围查询编辑

    返回包含提供范围内的术语的文档。

    gt :

      Greater than

    gte:

      Greater than or equal to

    lt :

      Less than
    lte :

      Less than or equal to
    format:
      (Optional, string) 日期格式
      用于在查询中转换日期值的日期格式
    relation:
      (Optional, string)
      指示范围查询如何与范围字段的值匹配。有效值为:

    • INTERSECTS (Default) 匹配文档,该文档的范围字段值与查询的范围相交
    • CONTAINS 使用范围字段值完全包含查询范围的文档进行匹配
    • WITHIN 使用完全在查询范围内的范围字段值来匹配文档。

    time_zone:
      (Optional, string)
      协调世界时(UTC)偏移量或IANA时区,用于将查询中的日期值转换为UTC。
    boost:
      浮点数,用于降低或增加查询的相关性分数。默认为1.0

    # 以下搜索返回文档,其中该age字段包含10和之间的术语20。
    curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
    {
      "query": {
        "range": {
          "age": {
            "gte": 10,
            "lte": 20,
            "boost": 2.0
          }
        }
      }
    }
    '
    # 例如,以下搜索返回文档,其中timestamp字段包含今天和昨天之间的日期。
    curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
    {
      "query": {
        "range": {
          "timestamp": {
            "gte": "now-1d/d",
            "lt": "now/d"
          }
        }
      }
    }
    '
    # 您可以使用time_zone参数使用UTC偏移量将日期值转换为UTC。例如:
    curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
    {
      "query": {
        "range": {
          "timestamp": {
            "time_zone": "+01:00",        
            "gte": "2020-01-01T00:00:00", 
            "lte": "now"                  
          }
        }
      }
    }
    '
    #指示日期值使用+01:00的UTC偏移量。
    #使用+01:00的UTC偏移量,Elasticsearch将此日期转换为2019-12-31T23:00:00 UTC。
    #time_zone参数不会影响现在的值。

    https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html

  • 相关阅读:
    活动安排问题
    喵哈哈村的魔法考试 Round #5 (Div.2) C
    梯度下降,牛顿法 ,高斯牛顿法
    SSD模型解析
    训练较深的卷积神经网络时遇到的问题
    手写体识别
    Fast Patch-based Style Transfer of Arbitrary Style 理解
    多任务学习
    迁移学习(训练数据少的可怜时的办法)
    通过训练得出的结果修改模型
  • 原文地址:https://www.cnblogs.com/Mint-diary/p/14463399.html
Copyright © 2011-2022 走看看