Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
A QueryParser which constructs queries to search multiple fields. More...
Inherits Lucene.Net.QueryParsers.QueryParser.
Public Member Functions | |
MultiFieldQueryParser (Version matchVersion, string[] fields, Analyzer analyzer, IDictionary< string, float > boosts) | |
Creates a MultiFieldQueryParser. Allows passing of a map with term to Boost, and the boost to apply to each term. | |
MultiFieldQueryParser (Version matchVersion, System.String[] fields, Analyzer analyzer) | |
Creates a MultiFieldQueryParser. | |
Public Member Functions inherited from Lucene.Net.QueryParsers.QueryParser | |
QueryParser (Version matchVersion, String f, Analyzer a) | |
virtual Query | Parse (String query) |
Parses a query string, returning a Lucene.Net.Search.Query. | |
virtual void | SetDateResolution (DateTools.Resolution dateResolution) |
Sets the default date resolution used by RangeQueries for fields for which no specific date resolutions has been set. Field specific resolutions can be set with SetDateResolution(String, DateTools.Resolution). | |
virtual void | SetDateResolution (String fieldName, DateTools.Resolution dateResolution) |
Sets the date resolution used by RangeQueries for a specific field. | |
virtual DateTools.Resolution | getDateResolution (String fieldName) |
Returns the date resolution that is used by RangeQueries for the given field. Returns null, if no default or field specific date resolution has been set for the given field. | |
int | Conjunction () |
int | Modifiers () |
Query | TopLevelQuery (String field) |
Query | Query (String field) |
Query | Clause (String field) |
Query | Term (String field) |
void | ReInit (ICharStream stream) |
Reinitialise. | |
void | ReInit (QueryParserTokenManager tm) |
Reinitialise. | |
Token | GetNextToken () |
Get the next Token. | |
Token | getToken (int index) |
Get the specific Token. | |
virtual ParseException | GenerateParseException () |
Generate ParseException. | |
void | Enable_tracing () |
Enable tracing. | |
void | Disable_tracing () |
Disable tracing. | |
Static Public Member Functions | |
static Query | Parse (Version matchVersion, System.String[] queries, System.String[] fields, Analyzer analyzer) |
Parses a query which searches on the fields specified. If x fields are specified, this effectively constructs: | |
static Query | Parse (Version matchVersion, System.String query, System.String[] fields, Occur[] flags, Analyzer analyzer) |
Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited. Uasge: | |
static Query | Parse (Version matchVersion, System.String[] queries, System.String[] fields, Occur[] flags, Analyzer analyzer) |
Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited. Usage: | |
Static Public Member Functions inherited from Lucene.Net.QueryParsers.QueryParser | |
static String | Escape (String s) |
Returns a String where those characters that QueryParser expects to be escaped are escaped by a preceding </c>. | |
static void | Main (String[] args) |
Command line tool to test QueryParser, using Lucene.Net.Analysis.SimpleAnalyzer. Usage:java Lucene.Net.QueryParsers.QueryParser <input> | |
Additional Inherited Members | |
Public Types inherited from Lucene.Net.QueryParsers.QueryParser | |
enum | Operator { OR, AND } |
Public Attributes inherited from Lucene.Net.QueryParsers.QueryParser | |
QueryParserTokenManager | token_source |
Token | token |
Token | jj_nt |
Static Public Attributes inherited from Lucene.Net.QueryParsers.QueryParser | |
static Operator | AND_OPERATOR = Operator.AND |
Alternative form of QueryParser.Operator.AND | |
static Operator | OR_OPERATOR = Operator.OR |
Alternative form of QueryParser.Operator.OR | |
Protected Member Functions inherited from Lucene.Net.QueryParsers.QueryParser | |
QueryParser (QueryParserTokenManager tm) | |
Constructor with generated Token Manager. | |
Protected Attributes inherited from Lucene.Net.QueryParsers.QueryParserConstants | |
const int | RangeExToken = 1 |
Lexical state. | |
Properties inherited from Lucene.Net.QueryParsers.QueryParser | |
virtual Analyzer | Analyzer [get] |
Returns the analyzer. | |
virtual string | Field [get] |
Returns the field. | |
virtual float | FuzzyMinSim [get, set] |
Gets or sets the minimal similarity for fuzzy queries. Default is 0.5f. | |
virtual int | FuzzyPrefixLength [get, set] |
Gets or sets the prefix length for fuzzy queries. | |
virtual int | PhraseSlop [get, set] |
Gets or sets the default slop for phrases. If zero, then exact phrase matches are required. Default value is zero. | |
virtual bool | AllowLeadingWildcard [get, set] |
Set to true to allow leading wildcard characters. When set, * or ? are allowed as the first character of a PrefixQuery and WildcardQuery. Note that this can produce very slow queries on big indexes. Default: false. | |
virtual bool | EnablePositionIncrements [get, set] |
Set to true to enable position increments in result query. When set, result phrase and multi-phrase queries will be aware of position increments. Useful when e.g. a StopFilter increases the position increment of the token that follows an omitted token. Default: false. | |
virtual Operator | DefaultOperator [get, set] |
Gets or sets the boolean operator of the QueryParser. In default mode (OR_OPERATOR ) terms without any modifiers are considered optional: for example capital of Hungary is equal to capital OR of OR Hungary .In AND_OPERATOR mode terms are considered to be in conjunction: the above mentioned query is parsed as capital AND of AND Hungary | |
virtual bool | LowercaseExpandedTerms [get, set] |
Whether terms of wildcard, prefix, fuzzy and range queries are to be automatically lower-cased or not. Default is true . | |
virtual RewriteMethod | MultiTermRewriteMethod [get, set] |
By default QueryParser uses MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it a) Runs faster b) Does not have the scarcity of terms unduly influence score c) avoids any "TooManyBooleanClauses" exception. However, if your application really needs to use the old-fashioned BooleanQuery expansion rewriting and the above points are not relevant then use this to change the rewrite method. | |
virtual CultureInfo | Locale [get, set] |
Gets or sets locale used by date range parsing. | |
virtual CompareInfo | RangeCollator [get, set] |
Gets or sets the collator used to determine index term inclusion in ranges for RangeQuerys. WARNING: Setting the rangeCollator to a non-null collator using this method will cause every single index Term in the Field referenced by lowerTerm and/or upperTerm to be examined. Depending on the number of index Terms in this Field, the operation could be very slow. | |
A QueryParser which constructs queries to search multiple fields.
<version>
</version>
Definition at line 37 of file MultiFieldQueryParser.cs.
Lucene.Net.QueryParsers.MultiFieldQueryParser.MultiFieldQueryParser | ( | Version | matchVersion, |
string[] | fields, | ||
Analyzer | analyzer, | ||
IDictionary< string, float > | boosts | ||
) |
Creates a MultiFieldQueryParser. Allows passing of a map with term to Boost, and the boost to apply to each term.
It will, when parse(String query) is called, construct a query like this (assuming the query consists of two terms and you specify the two fields title
and body
):
(title:term1 body:term1) (title:term2 body:term2)
When setDefaultOperator(AND_OPERATOR) is set, the result will be:
+(title:term1 body:term1) +(title:term2 body:term2)
When you pass a boost (title=>5 body=>10) you can get
+(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.
Definition at line 76 of file MultiFieldQueryParser.cs.
Lucene.Net.QueryParsers.MultiFieldQueryParser.MultiFieldQueryParser | ( | Version | matchVersion, |
System.String[] | fields, | ||
Analyzer | analyzer | ||
) |
Creates a MultiFieldQueryParser.
It will, when parse(String query) is called, construct a query like this (assuming the query consists of two terms and you specify the two fields title
and body
):
(title:term1 body:term1) (title:term2 body:term2)
When setDefaultOperator(AND_OPERATOR) is set, the result will be:
+(title:term1 body:term1) +(title:term2 body:term2)
In other words, all the query's terms must appear, but it doesn't matter in what fields they appear.
Definition at line 107 of file MultiFieldQueryParser.cs.
|
static |
Parses a query which searches on the fields specified. If x fields are specified, this effectively constructs:
(field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
matchVersion | Lucene version to match; this is passed through to QueryParser. |
queries | Queries strings to parse |
fields | Fields to search on |
analyzer | Analyzer to use |
<throws> ParseException </throws>
if query parsing fails
<throws> IllegalArgumentException </throws>
if the length of the queries array differs from the length of the fields array
Definition at line 245 of file MultiFieldQueryParser.cs.
|
static |
Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited. Uasge:
String[] fields = {"filename", "contents", "description"}; BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD, BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT}; MultiFieldQueryParser.parse("query", fields, flags, analyzer);
The code above would construct a query:
(filename:query) +(contents:query) -(description:query)
matchVersion | Lucene version to match; this is passed through to QueryParser. |
query | Query string to parse |
fields | Fields to search on |
flags | Flags describing the fields |
analyzer | Analyzer to use |
<throws> ParseException </throws>
if query parsing fails
<throws> IllegalArgumentException </throws>
if the length of the fields array differs from the length of the flags array
Definition at line 299 of file MultiFieldQueryParser.cs.
|
static |
Parses a query, searching on the fields specified. Use this if you need to specify certain fields as required, and others as prohibited. Usage:
String[] query = {"query1", "query2", "query3"}; String[] fields = {"filename", "contents", "description"}; BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD, BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT}; MultiFieldQueryParser.parse(query, fields, flags, analyzer);
The code above would construct a query:
(filename:query1) +(contents:query2) -(description:query3)
matchVersion | Lucene version to match; this is passed through to QueryParser. |
queries | Queries string to parse |
fields | Fields to search on |
flags | Flags describing the fields |
analyzer | Analyzer to use |
<throws> ParseException </throws>
if query parsing fails
<throws> IllegalArgumentException </throws>
if the length of the queries, fields, and flags array differ
Definition at line 353 of file MultiFieldQueryParser.cs.