Method Parse
Parse(LuceneVersion, 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(LuceneVersion matchVersion, string[] queries, string[] fields, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | Lucene version to match; this is passed through to QueryParser. |
System.String[] | queries | Queries strings to parse |
System.String[] | fields | Fields to search on |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ParseException | if query parsing fails |
System.ArgumentException | if the length of the queries array differs from the length of the fields array |
Parse(LuceneVersion, 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(LuceneVersion matchVersion, string query, string[] fields, Occur[] flags, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | Lucene version to match; this is passed through to QueryParser. |
System.String | query | Query string to parse |
System.String[] | fields | Fields to search on |
Occur[] | flags | Flags describing the fields |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ParseException | if query parsing fails |
System.ArgumentException | if the length of the fields array differs from the length of the flags array |
Parse(LuceneVersion, 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(LuceneVersion matchVersion, string[] queries, string[] fields, Occur[] flags, Analyzer analyzer)
Parameters
Type | Name | Description |
---|---|---|
LuceneVersion | matchVersion | Lucene version to match; this is passed through to QueryParser. |
System.String[] | queries | Queries string to parse |
System.String[] | fields | Fields to search on |
Occur[] | flags | Flags describing the fields |
Analyzer | analyzer | Analyzer to use |
Returns
Type | Description |
---|---|
Query |
Exceptions
Type | Condition |
---|---|
ParseException | if query parsing fails |
System.ArgumentException | if the length of the queries, fields, and flags array differ |