lucene 范围搜索表达式(range expression)

时间:2022-11-04 16:36:06
实际测试
lucene范围符号,大于等于或小于等于符号[],大于或小于符号{}
 
newIntRange或newLongRange一样
 
 
代码:
          // test lucene expression
          BooleanQuery bQuery = new BooleanQuery();
         
          // test range expression
         
          // +LPUBLISHTIME1:{1 TO 3}
          NumericRangeQuery numRangeQuery1 = NumericRangeQuery.newIntRange("lpublishtime1".toUpperCase(), 1, 3, false, false);
          bQuery.add(numRangeQuery1, BooleanClause.Occur.MUST);
          System.out.println(bQuery);
         
          // +LPUBLISHTIME2:[1 TO 3}
          NumericRangeQuery numRangeQuery2 = NumericRangeQuery.newIntRange("lpublishtime2".toUpperCase(), 1, 3, true, false);
          bQuery.add(numRangeQuery2, BooleanClause.Occur.MUST);
          System.out.println(bQuery);
         
          // +LPUBLISHTIME2:[1 TO 3]
          NumericRangeQuery numRangeQuery3 = NumericRangeQuery.newIntRange("lpublishtime2".toUpperCase(), 1, 3, true, true);
          bQuery.add(numRangeQuery3, BooleanClause.Occur.MUST);
          System.out.println(bQuery);