If the search query contains a leading wildcard character (*
or ?
), the QueryParser
's Parse
function throws an error.
Dim q As String = "*abc"
Dim qp As New QueryParser("text", New StandardAnalyzer())
Dim query As Query = qp.Parse(q)
Is there any way to solve this problem in Lucene.NET v2.0.0.4?
Set QueryParser.SetAllowLeadingWildcard Method to true. The API page states that "this can produce very slow queries on big indexes" though.
Maybe you have to use a WildcardQuery, but
You can avoid wildcard queries by utilizing
NGramFilter
for your index analyzer. Than you have to usesearch_analyzer
withoutNGramFilter
. This way you can search similar tolike "%text%"
without even needing wildcards. You just enter 'abc' and your index would be searched for all entries containing 'abc' very quickly.