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

  • 相关阅读:
    Cable master--hdu1551(二分法)
    Pie--hdu1969(二分法)
    Ice_cream's world I--hdu2120
    How Many Tables--hdu1213(并查集)
    畅通工程--hdu1232(并查集)
    小希的迷宫--hdu1272(并查集)
    More is better--hdu1856(并查集)
    Windows Message Queue--hdu1509
    期末考试--nyoj-757
    网络开发之使用Web Service和使用WCF服务
  • 原文地址:https://www.cnblogs.com/Mint-diary/p/14463399.html
Copyright © 2011-2022 走看看