Class QueryParserUtil
This class defines utility methods to (help) parse query strings into Lucene.Net.Search.Query objects.
Inherited Members
Namespace: Lucene.Net.QueryParsers.Flexible.Standard
Assembly: Lucene.Net.QueryParser.dll
Syntax
public sealed class QueryParserUtil
Methods
Escape(string)
Returns a string where those characters that TextParser expects to be
escaped are escaped by a preceding </code>.
Declaration
public static string Escape(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s |
Returns
Type | Description |
---|---|
string |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Parse(string, string[], Occur[], 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:string[] fields = {"filename", "contents", "description"};
Occur[] flags = {Occur.SHOULD,
Occur.MUST,
Occur.MUST_NOT};
MultiFieldQueryParser.Parse("query", fields, flags, analyzer);
The code above would construct a query:
(filename:query) +(contents:query) -(description:query)
Declaration
public static Query Parse(string query, string[] fields, Occur[] flags, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
string | query | Query string to parse |
string[] | fields | Fields to search on |
Occur[] | flags | Flags describing the fields |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ArgumentException | if the length of the fields array differs from the length of the flags array |
ArgumentNullException |
|
Parse(string[], string[], Analyzer)
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)
Declaration
public static Query Parse(string[] queries, string[] fields, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
string[] | queries | Queries strings to parse |
string[] | fields | Fields to search on |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ArgumentException | if the length of the queries array differs from the length of the fields array |
ArgumentNullException |
|
Parse(string[], string[], Occur[], 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:string[] query = {"query1", "query2", "query3"};
string[] fields = {"filename", "contents", "description"};
Occur[] flags = {Occur.SHOULD,
Occur.MUST,
Occur.MUST_NOT};
MultiFieldQueryParser.Parse(query, fields, flags, analyzer);
The code above would construct a query:
(filename:query1) +(contents:query2) -(description:query3)
Declaration
public static Query Parse(string[] queries, string[] fields, Occur[] flags, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
string[] | queries | Queries string to parse |
string[] | fields | Fields to search on |
Occur[] | flags | Flags describing the fields |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ArgumentException | if the length of the queries, fields, and flags array differ |
ArgumentNullException |
|