Lucene.Net.QueryParsers.QueryParser.GetWildcardQuery C# (CSharp) Method

GetWildcardQuery() protected method

Factory method for generating a query. Called when parser parses an input term token that contains one or more wildcard characters (? and *), but is not a prefix term token (one that has just a single * character at the end)

Depending on settings, prefix term may be lower-cased automatically. It will not go through the default Analyzer, however, since normal Analyzers are unlikely to work properly with wildcard templates.

Can be overridden by extending classes, to provide custom handling for wildcard queries, which may be necessary due to missing analyzer calls.

throw in overridden method to disallow ///
protected GetWildcardQuery ( String field, String termStr ) : Query
field String Name of the field query will use. ///
termStr String Term token that contains one or more wild card /// characters (? or *), but is not simple prefix term /// ///
return Lucene.Net.Search.Query
        protected internal virtual Query GetWildcardQuery(String field, String termStr)
        {
            if ("*".Equals(field))
            {
                if ("*".Equals(termStr)) return NewMatchAllDocsQuery();
            }
            if (!allowLeadingWildcard && (termStr.StartsWith("*") || termStr.StartsWith("?")))
                throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
            if (lowercaseExpandedTerms)
            {
                termStr = termStr.ToLower();
            }
            Term t = new Term(field, termStr);
            return NewWildcardQuery(t);
        }