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

  • 相关阅读:
    C# Json数组序列化和反序列总结
    从Excel文件中读取内容
    JS replace()用法实现replaceAll
    JS 缓存
    JS 从HTML页面获取自定义属性值
    根据IP和端口号异步短时间判断服务器是否链接
    时间戳与时间相互转换(13位)(转)
    JS enter事件及数据不完整阻止下一步操作
    JS 检测浏览器中是否安装了特定的插件
    C# Cache 缓存
  • 原文地址:https://www.cnblogs.com/Mint-diary/p/14463399.html
Copyright © 2011-2022 走看看