如何在Lucene 6.x中实例化BooleanQuery?如何使用布尔查询在其中添加其他查询?
在Lucene 4.x中,我们使用BooleanQuery如下:
BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(query1, BooleanClause.Occur.MUST);
booleanQuery.add(query2, BooleanClause.Occur.MUST);
Run Code Online (Sandbox Code Playgroud)
如何在Lucene 6中实现这一目标.
我有一个名为Color的类,其中有三个静态对象(使用相同的类本身实例化)和一个int类型(称为i)变量.当我运行类时,'i'变量在构造函数中是递增的,但它不会在内存中持久存在,请在下面解释这个代码
package test;
public class Color
{
public static Color RED = new Color();
public static final Color BLUE = new Color();
public static final Color GREEN = new Color();
static int i=0;
Color(){
System.out.println("Incrementing 'i' here "+(++i));
}
public static void main(String[] args) {
System.out.println("The 'i' variable is not incremented here, it still shows '0' , 'i' is: "+ Color.i ); // line 14
Color x = new Color();
System.out.println(x.i);
}
}
Run Code Online (Sandbox Code Playgroud)
出局如下:
Incrementing 'i' here 1
Incrementing 'i' …Run Code Online (Sandbox Code Playgroud)