Show / Hide Table of Contents

    Class QueryParserUtil

    This class defines utility methods to (help) parse query strings into objects.

    Inheritance
    System.Object
    QueryParserUtil
    Namespace: Lucene.Net.QueryParsers.Flexible.Standard
    Assembly: Lucene.Net.QueryParser.dll
    Syntax
    public sealed class QueryParserUtil : object

    Methods

    | Improve this Doc View Source

    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
    System.String s
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    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
    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
    | Improve this Doc View Source

    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
    System.String[] queries

    Queries strings to parse

    System.String[] fields

    Fields to search on

    Analyzer analyzer

    Analyzer to use

    Returns
    Type Description
    Query
    | Improve this Doc View Source

    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
    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
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)