Class AnalyzingQueryParser
Overrides Lucene's default QueryParser so that Fuzzy-, Prefix-, Range-, and WildcardQuerys
are also passed through the given analyzer, but wildcard characters *
and
?
don't get removed from the search terms.
Warning: This class should only be used with analyzers that do not use stopwords
or that add tokens. Also, several stemming analyzers are inappropriate: for example, GermanAnalyzer
will turn Häuser
into hau
, but H?user
will
become h?user
when using this parser and thus no match would be found (i.e.
using this parser will be no improvement over QueryParser in such cases).
Implements
Inherited Members
Namespace: Lucene.Net.QueryParsers.Analyzing
Assembly: Lucene.Net.QueryParser.dll
Syntax
public class AnalyzingQueryParser : QueryParser, ICommonQueryParserConfiguration
Constructors
| Improve this Doc View SourceAnalyzingQueryParser(LuceneVersion, String, Analyzer)
Declaration
public AnalyzingQueryParser(LuceneVersion matchVersion, string field, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | |
System.String | field | |
Analyzer | analyzer |
Methods
| Improve this Doc View SourceAnalyzeSingleChunk(String, String, String)
Returns the analyzed form for the given chunk.
If the analyzer produces more than one output token from the given chunk, a ParseException is thrown.
Declaration
protected virtual string AnalyzeSingleChunk(string field, string termStr, string chunk)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | The target field |
System.String | termStr | The full term from which the given chunk is excerpted |
System.String | chunk | The portion of the given termStr to be analyzed |
Returns
Type | Description |
---|---|
System.String | The result of analyzing the given chunk |
Exceptions
Type | Condition |
---|---|
ParseException | ParseException when analysis returns other than one output token |
GetFuzzyQuery(String, String, Single)
Called when parser parses an input term that has the fuzzy suffix (~) appended.
Depending on analyzer and settings, a fuzzy term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
Declaration
protected override Query GetFuzzyQuery(string field, string termStr, float minSimilarity)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of the field query will use. |
System.String | termStr | Term to use for building term for the query |
System.Single | minSimilarity |
Returns
Type | Description |
---|---|
Query | Resulting |
Overrides
| Improve this Doc View SourceGetPrefixQuery(String, String)
Called when parser parses an input term 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 analyzer and settings, a prefix term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
Declaration
protected override Query GetPrefixQuery(string field, string termStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of the field query will use. |
System.String | termStr | Term to use for building term for the query (without trailing '*' character!) |
Returns
Type | Description |
---|---|
Query | Resulting |
Overrides
| Improve this Doc View SourceGetWildcardQuery(String, String)
Called when parser parses an input term 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 analyzer and settings, a prefix term may (most probably will) be lower-cased automatically. It will go through the default Analyzer.
Overrides super class, by passing terms through analyzer.
Declaration
protected override Query GetWildcardQuery(string field, string termStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | field | Name of the field query will use. |
System.String | termStr | Term to use for building term for the query (without trailing '*' character!) |
Returns
Type | Description |
---|---|
Query | Resulting |