我是Lucene的新手(实际上只是学习的第二天)。我想在1距离内进行接近搜索,例如" Hello"one_answers" World"。我读了https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#proximenty searches网站,发现我必须做" Hello World" 〜1。所以,我尝试的是
QueryParser QP = new QueryParser("text", analyzer);
Query qry = QP.parse("hello world"~1);
这给了一个错误,所以我做了
QueryParser QP = new QueryParser("text", analyzer);
Query qry = QP.parse("hello world~1");
这没有给出错误,但没有给出我想要的答案。它返回了一个布尔搜索结果,它只是任何文档,带有" Hello"one_answers" World"因此,我打印了Qry,如果我的猜测是正确的,我的text:hello text:world~1
不是text:hello word~1
。
任何人可以帮助我如何使用QueryParser来看一下?
谢谢!
我会尝试
Query qry = QP.parse(""hello world"~1");