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

GetPrefixQuery() protected method

Factory method for generating a query (similar to {@link #getWildcardQuery}). Called when parser parses an input term token that uses prefix notation; that is, contains a single '*' wildcard character as its last character. Since this is a special case of generic wildcard term, and such a query can be optimized easily, this usually results in a different query object.

Depending on settings, a 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 wild card queries, which may be necessary due to missing analyzer calls.

throw in overridden method to disallow ///
protected GetPrefixQuery ( String field, String termStr ) : Query
field String Name of the field query will use. ///
termStr String Term token to use for building term for the query /// (without trailing '*' character!) /// ///
return Lucene.Net.Search.Query
        protected internal virtual Query GetPrefixQuery(String field, String termStr)
        {
            if (!allowLeadingWildcard && termStr.StartsWith("*"))
                throw new ParseException("'*' not allowed as first character in PrefixQuery");
            if (lowercaseExpandedTerms)
            {
                termStr = termStr.ToLower();
            }
            Term t = new Term(field, termStr);
            return NewPrefixQuery(t);
        }