Wildcard at the Beginning of a searchterm -Lucene

后端 未结 1 1090
轻奢々
轻奢々 2020-12-20 15:19

As far as i know lucene(.net) doesn\'t support the wildcard at the beginning of a searchterm --> http://lucene.apache.org/java/2_0_0/queryparsersyntax.html \"Note: You canno

相关标签:
1条回答
  • 2020-12-20 15:56

    Your question is tagged with Lucene.NET so I assume you mean the .NET version rather than the Java version.

    Yes, you can have wildcards at the beginning of a search term by via

    var queryParser = new QueryParser(LuceneVersion, "content", new StandardAnalyzer(LuceneVersion));
    queryParser.SetAllowLeadingWildcard(true);
    

    but you need to be aware of the performance consequences. Find more detailed source code in this blog.

    Since Lucene.NET is a port of the Java version, I suspect you could use the same approach for the Java version. I didn't verify this, though.

    0 讨论(0)
提交回复
热议问题