QueryBuilder

open class QueryBuilder(var analyzer: Analyzer = StandardAnalyzer())

Creates queries from the Analyzer chain.

Example usage:

QueryBuilder builder = new QueryBuilder(analyzer);
Query a = builder.createBooleanQuery("body", "just a test");
Query b = builder.createPhraseQuery("body", "another test");
Query c = builder.createMinShouldMatchQuery("body", "another test", 0.5f);
*

This can also be used as a subclass for query parsers to make it easier to interact with the analysis chain. Factory methods such as newTermQuery are provided so that the generated queries can be customized.

Constructors

Link copied to clipboard
constructor(analyzer: Analyzer = StandardAnalyzer())

Types

Link copied to clipboard
class TermAndBoost(term: BytesRef, val boost: Float)

Wraps a term and boost

Properties

Link copied to clipboard
Link copied to clipboard

Set to true if phrase queries should be automatically generated for multi terms synonyms. Default: false.

Link copied to clipboard

Enable or disable graph TokenStream processing (enabled by default).

Link copied to clipboard

Set to true to enable position increments in result query.

Functions

Link copied to clipboard
fun createBooleanQuery(field: String, queryText: String, operator: BooleanClause.Occur = BooleanClause.Occur.SHOULD): Query?

Creates a boolean query from the query text.

Link copied to clipboard
fun createMinShouldMatchQuery(field: String, queryText: String, fraction: Float): Query?

Creates a minimum-should-match query from the query text.

Link copied to clipboard
fun createPhraseQuery(field: String, queryText: String, phraseSlop: Int = 0): Query?

Creates a phrase query from the query text.