C# – Lucene – Wildcards in phrases

clucenelucene.netnet

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

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

Any assistance would be greatly appreciated

Best Answer

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.

Related Topic