C# Class Lucene.Net.QueryParsers.Flexible.Standard.QueryParserUtil

This class defines utility methods to (help) parse query strings into Query objects.
Exibir arquivo Open project: apache/lucenenet Class Usage Examples

Public Methods

Method Description
Escape ( string s ) : string

Returns a string where those characters that TextParser expects to be escaped are escaped by a preceding \.

Parse ( string queries, string fields, Analyzer analyzer ) : Query

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)

Parse ( string query, string fields, BooleanClause flags, Analyzer analyzer ) : Query

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"}; 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)

Method Details

Escape() public static method

Returns a string where those characters that TextParser expects to be escaped are escaped by a preceding \.
public static Escape ( string s ) : string
s string
return string

Parse() public static method

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)
/// if the length of the queries array differs from the length of the /// fields array ///
public static Parse ( string queries, string fields, Analyzer analyzer ) : Query
queries string Queries strings to parse
fields string Fields to search on
analyzer Lucene.Net.Analysis.Analyzer Analyzer to use
return Lucene.Net.Search.Query

Parse() public static method

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"}; 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)
/// if the length of the fields array differs from the length of the /// flags array ///
public static Parse ( string query, string fields, BooleanClause flags, Analyzer analyzer ) : Query
query string Query string to parse
fields string Fields to search on
flags Lucene.Net.Search.BooleanClause Flags describing the fields
analyzer Lucene.Net.Analysis.Analyzer Analyzer to use
return Lucene.Net.Search.Query