zoukankan      html  css  js  c++  java
  • elasticSearch RangeQuery范围查询from to的理解

    elasticSearch RangeQuery范围查询from to的理解

    Elasticsearch Guide 选择版本号来查询对应的文档内容:
    https://www.elastic.co/guide/en/elasticsearch/reference/6.7/index.html

     

    需要根据版本号来查询:
    Elasticsearch Guide [6.7] Query DSL Term level queries Range Query
    https://www.elastic.co/guide/en/elasticsearch/reference/6.7/query-dsl-range-query.html

    查看RangeQueryBuilder.java源码内容:
    public static final boolean DEFAULT_INCLUDE_UPPER = true; //默认是包含
    public static final boolean DEFAULT_INCLUDE_LOWER = true; //默认是包含

    private boolean includeLower = DEFAULT_INCLUDE_LOWER;
    private boolean includeUpper = DEFAULT_INCLUDE_UPPER;

    /**
    * The from part of the range query. Null indicates unbounded. 默认是包含(大于等于)
    */
    public RangeQueryBuilder from(Object from) {
    return from(from, this.includeLower);
    }

    /**
    * The from part of the range query. Null indicates unbounded. 大于
    */
    public RangeQueryBuilder gt(Object from) {
    return from(from, false);
    }

    /**
    * The from part of the range query. Null indicates unbounded. 大于等于
    */
    public RangeQueryBuilder gte(Object from) {
    return from(from, true);
    }


    /**
    * The to part of the range query. Null indicates unbounded. 默认是包含(小于等于)
    */
    public RangeQueryBuilder to(Object to) {
    return to(to, this.includeUpper);
    }

    /**
    * The to part of the range query. Null indicates unbounded. 小于
    */
    public RangeQueryBuilder lt(Object to) {
    return to(to, false);
    }

    /**
    * The to part of the range query. Null indicates unbounded. 小于等于
    */
    public RangeQueryBuilder lte(Object to) {
    return to(to, true);
    }

    demo代码(三种方式):
    boolQueryBuilder.must(QueryBuilders.rangeQuery("field1").to(reqVO.getDate2()));
    boolQueryBuilder.must(QueryBuilders.rangeQuery("field2").from(reqVO.getDate1()));
    boolQueryBuilder.must(QueryBuilders.rangeQuery("field2").from(reqVO.getDate1())).to(reqVO.getDate2()));

  • 相关阅读:
    [洛谷P4774] [NOI2018]屠龙勇士
    [洛谷P3338] [ZJOI2014]力
    [洛谷P1707] 刷题比赛
    svn查看指定版本提交信息的命令
    ajax无刷新上传文件
    给docker里的php安装gd扩展
    PHP基于openssl实现的非对称加密操作
    php获取文件扩展名
    javascript格式化日期
    javascript获取url参数
  • 原文地址:https://www.cnblogs.com/oktokeep/p/15475327.html
Copyright © 2011-2022 走看看