Lucene的 - 在短语通配符通配符、短语、Lucene

2023-09-02 11:58:46 作者:  无人猜透我心

我目前正在尝试使用Lucene来填充搜索索引中的数据。

I am currently attempting to use Lucene to search data populated in an index.

我可以通过它括在方括号(即处理文件)的准确短语匹配,但不能得到Lucene来发现这句话做任何形式的处理文档*。

I can match on exact phrases by enclosing it in brackets (i.e. "Processing Documents"), but cannot get Lucene to find that phrase by doing any sort of "Processing Document*".

明显的区别是通配符在末端。

The obvious difference being the wildcard at the end.

我目前正在尝试使用卢克查看和搜索索引。 (它在解析时下降了星号,在这句话的结尾)

I am currently attempting to use Luke to view and search the index. (it drops the asterisk at the end of the phrase when parsing)

添加引号中的数据似乎是主要的罪魁祸首是搜索文档*的工作,但文件*并不

Adding the quotes around the data seems to be the main culprit as searching for document* will work, but "document*" does not

任何援助将大大AP preciated

Any assistance would be greatly appreciated

推荐答案

不仅在QueryParser的不支持词组通配符,PhraseQuery本身只支持条款。 MultiPhraseQuery 更接近,但由于其总结说,你仍然需要枚举IndexReader.terms自己相匹配的通配符。

Not only does the QueryParser not support wildcards in phrases, PhraseQuery itself only supports Terms. MultiPhraseQuery comes closer, but as its summary says, you still need to enumerate the IndexReader.terms yourself to match the wildcard.