• API

    Show / Hide Table of Contents

    Namespace Lucene.Net.QueryParsers.Flexible.Standard

    Implementation of the {@linkplain org.apache.lucene.queryparser.classic Lucene classic query parser} using the flexible query parser frameworks

    Lucene Flexible Query Parser Implementation

    The old Lucene query parser used to have only one class that performed all the parsing operations. In the new query parser structure, the parsing was divided in 3 steps: parsing (syntax), processing (semantic) and building.

    The classes contained in the package org.apache.lucene.queryParser.standard are used to reproduce the same behavior as the old query parser.

    Check StandardQueryParser to quick start using the Lucene query parser.

    Classes

    QueryParserUtil

    This class defines utility methods to (help) parse query strings into Lucene.Net.Search.Query objects.

    StandardQueryParser

    This class is a helper that enables users to easily use the Lucene query parser.

    To construct a Query object from a query string, use the Parse(String, String) method:

    StandardQueryParser queryParserHelper = new StandardQueryParser();
    Query query = queryParserHelper.Parse("a AND b", "defaultField");

    To change any configuration before parsing the query string do, for example:

    // the query config handler returned by StandardQueryParser is a
    // StandardQueryConfigHandler
    queryParserHelper.QueryConfigHandler.Analyzer = new WhitespaceAnalyzer();

    The syntax for query strings is as follows (copied from the old QueryParser javadoc):

    A Query is a series of clauses. A clause may be prefixed by:

    • a plus (+) or a minus (-) sign, indicating that the clause is required or prohibited respectively; or
    • a term followed by a colon, indicating the field to be searched. This enables one to construct queries which search multiple fields.
    A clause may be either:
    • a term, indicating all the documents that contain this term; or
    • a nested query, enclosed in parentheses. Note that this may be used with a +/- prefix to require any of a set of terms.
    Thus, in BNF, the query grammar is:
        Query  ::= ( Clause )*
        Clause ::= ["+", "-"] [<TERM> ":"] ( <TERM> | "(" Query ")" )

    Examples of appropriately formatted queries can be found in the query syntax documentation.

    The text parser used by this helper is a StandardSyntaxParser.

    The query node processor used by this helper is a StandardQueryNodeProcessorPipeline.

    The builder used by this helper is a StandardQueryTreeBuilder.

    Interfaces

    ICommonQueryParserConfiguration

    Configuration options common across queryparser implementations.

    • Improve this Doc
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)