Table of Contents

Class LuceneSearchQueryBase

Namespace
Examine.Lucene.Search
Assembly
Examine.Lucene.dll

Represents a base for LuceneSearchQuery

public abstract class LuceneSearchQueryBase : IQuery, INestedQuery
Inheritance
LuceneSearchQueryBase
Implements
Derived
Inherited Members

Constructors

LuceneSearchQueryBase(CustomMultiFieldQueryParser, string?, LuceneSearchOptions, BooleanOperation)

protected LuceneSearchQueryBase(CustomMultiFieldQueryParser queryParser, string? category, LuceneSearchOptions searchOptions, BooleanOperation occurance)

Parameters

queryParser CustomMultiFieldQueryParser
category string
searchOptions LuceneSearchOptions
occurance BooleanOperation

Properties

AllFields

All the searchable fields of the query

public string[] AllFields { get; }

Property Value

string[]

BooleanOperation

The type of boolean operation

public BooleanOperation BooleanOperation { get; set; }

Property Value

BooleanOperation

Category

The category of the query

public string? Category { get; }

Property Value

string

Occurrence

Specifies how clauses are to occur in matching documents

protected Occur Occurrence { get; set; }

Property Value

Occur

Query

The Lucene.Net.Search.BooleanQuery

public BooleanQuery Query { get; }

Property Value

BooleanQuery

QueryParser

The query parser of the query

public QueryParser QueryParser { get; }

Property Value

QueryParser

SearchOptions

The query search options

public LuceneSearchOptions SearchOptions { get; }

Property Value

LuceneSearchOptions

SortFields

The sort fields of the query

public IList<SortField> SortFields { get; }

Property Value

IList<SortField>

Methods

All()

Matches all items

public IOrdering All()

Returns

IOrdering

CreateOp()

protected abstract LuceneBooleanOperationBase CreateOp()

Returns

LuceneBooleanOperationBase

Field(string, IExamineValue)

Query on the specified field

public IBooleanOperation Field(string fieldName, IExamineValue fieldValue)

Parameters

fieldName string

Name of the field.

fieldValue IExamineValue

The field value.

Returns

IBooleanOperation

Field(string, string)

Query on the specified field

public IBooleanOperation Field(string fieldName, string fieldValue)

Parameters

fieldName string

Name of the field.

fieldValue string

The field value.

Returns

IBooleanOperation

FieldInternal(string, IExamineValue, Occur)

protected LuceneBooleanOperationBase FieldInternal(string fieldName, IExamineValue fieldValue, Occur occurrence)

Parameters

fieldName string
fieldValue IExamineValue
occurrence Occur

Returns

LuceneBooleanOperationBase

FieldNested<T>(string, T)

Query on a specific field

protected abstract INestedBooleanOperation FieldNested<T>(string fieldName, T fieldValue) where T : struct

Parameters

fieldName string
fieldValue T

Returns

INestedBooleanOperation

Type Parameters

T

Field<T>(string, T)

Query on the specified field for a struct value which will try to be auto converted with the correct query

public abstract IBooleanOperation Field<T>(string fieldName, T fieldValue) where T : struct

Parameters

fieldName string
fieldValue T

Returns

IBooleanOperation

Type Parameters

T

GetFieldInternalQuery(string, IExamineValue, bool)

Returns the Lucene query object for a field given an IExamineValue

protected virtual Query? GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser)

Parameters

fieldName string
fieldValue IExamineValue
useQueryParser bool

True to use the query parser to parse the search text, otherwise, manually create the queries

Returns

Query

A new IBooleanOperation with the clause appended

Group(Func<INestedQuery, INestedBooleanOperation>, BooleanOperation)

Creates an inner group query

public IBooleanOperation Group(Func<INestedQuery, INestedBooleanOperation> inner, BooleanOperation defaultOp = BooleanOperation.Or)

Parameters

inner Func<INestedQuery, INestedBooleanOperation>
defaultOp BooleanOperation

The default operation is OR, generally a grouped query would have complex inner queries with an OR against another complex group query

Returns

IBooleanOperation

GroupedAnd(IEnumerable<string>, params IExamineValue[]?)

Queries multiple fields with each being an And boolean operation

public IBooleanOperation GroupedAnd(IEnumerable<string> fields, params IExamineValue[]? fieldVals)

Parameters

fields IEnumerable<string>

The fields.

fieldVals IExamineValue[]

Returns

IBooleanOperation

GroupedAnd(IEnumerable<string>, params string[])

Queries multiple fields with each being an And boolean operation

public IBooleanOperation GroupedAnd(IEnumerable<string> fields, params string[] query)

Parameters

fields IEnumerable<string>

The fields.

query string[]

The query.

Returns

IBooleanOperation

GroupedAndInternal(string[], IExamineValue[]?, Occur)

protected LuceneBooleanOperationBase GroupedAndInternal(string[] fields, IExamineValue[]? fieldVals, Occur occurrence)

Parameters

fields string[]
fieldVals IExamineValue[]
occurrence Occur

Returns

LuceneBooleanOperationBase

GroupedNot(IEnumerable<string>, params IExamineValue[])

Queries multiple fields with each being an Not boolean operation

public IBooleanOperation GroupedNot(IEnumerable<string> fields, params IExamineValue[] query)

Parameters

fields IEnumerable<string>

The fields.

query IExamineValue[]

The query.

Returns

IBooleanOperation

GroupedNot(IEnumerable<string>, params string[])

Queries multiple fields with each being an Not boolean operation

public IBooleanOperation GroupedNot(IEnumerable<string> fields, params string[] query)

Parameters

fields IEnumerable<string>

The fields.

query string[]

The query.

Returns

IBooleanOperation

GroupedNotInternal(string[], IExamineValue[])

protected LuceneBooleanOperationBase GroupedNotInternal(string[] fields, IExamineValue[] fieldVals)

Parameters

fields string[]
fieldVals IExamineValue[]

Returns

LuceneBooleanOperationBase

GroupedOr(IEnumerable<string>, params IExamineValue[]?)

Queries multiple fields with each being an Or boolean operation

public IBooleanOperation GroupedOr(IEnumerable<string> fields, params IExamineValue[]? query)

Parameters

fields IEnumerable<string>

The fields.

query IExamineValue[]

The query.

Returns

IBooleanOperation

GroupedOr(IEnumerable<string>, params string[])

Queries multiple fields with each being an Or boolean operation

public IBooleanOperation GroupedOr(IEnumerable<string> fields, params string[] query)

Parameters

fields IEnumerable<string>

The fields.

query string[]

The query.

Returns

IBooleanOperation

GroupedOrInternal(string[], IExamineValue[]?, Occur)

protected LuceneBooleanOperationBase GroupedOrInternal(string[] fields, IExamineValue[]? fieldVals, Occur occurrence)

Parameters

fields string[]
fieldVals IExamineValue[]
occurrence Occur

Returns

LuceneBooleanOperationBase

Id(string)

Query on the id

public IBooleanOperation Id(string id)

Parameters

id string

The id.

Returns

IBooleanOperation

IdInternal(string, Occur)

protected LuceneBooleanOperationBase IdInternal(string id, Occur occurrence)

Parameters

id string
occurrence Occur

Returns

LuceneBooleanOperationBase

LuceneQuery(Query, BooleanOperation?)

Adds a true Lucene Query

public LuceneBooleanOperationBase LuceneQuery(Query query, BooleanOperation? op = null)

Parameters

query Query
op BooleanOperation?

Returns

LuceneBooleanOperationBase

ManagedQuery(string, string[]?)

The index will determine the most appropriate way to search given the query and the fields provided

public abstract IBooleanOperation ManagedQuery(string query, string[]? fields = null)

Parameters

query string
fields string[]

Returns

IBooleanOperation

ManagedQueryNested(string, string[]?)

The index will determine the most appropiate way to query the fields specified

protected abstract INestedBooleanOperation ManagedQueryNested(string query, string[]? fields = null)

Parameters

query string
fields string[]

Returns

INestedBooleanOperation

NativeQuery(string)

Passes a text string which is preformatted for the underlying search API. Examine will not modify this

public IBooleanOperation NativeQuery(string query)

Parameters

query string

The query.

Returns

IBooleanOperation

Remarks

This allows a developer to completely bypass and Examine logic and comprise their own query text which they are passing in. It means that if the search is too complex to achieve with the fluent API, or too dynamic to achieve with a static language the provider can still handle it.

RangeQueryNested<T>(string[], T?, T?, bool, bool)

Matches items as defined by the IIndexFieldValueType used for the fields specified. If a type is not defined for a field name, or the type does not implement IIndexRangeValueType for the types of min and max, nothing will be added

protected abstract INestedBooleanOperation RangeQueryNested<T>(string[] fields, T? min, T? max, bool minInclusive = true, bool maxInclusive = true) where T : struct

Parameters

fields string[]
min T?
max T?
minInclusive bool
maxInclusive bool

Returns

INestedBooleanOperation

Type Parameters

T

RangeQuery<T>(string[], T?, T?, bool, bool)

Matches items as defined by the IIndexFieldValueType used for the fields specified. If a type is not defined for a field name, or the type does not implement IIndexRangeValueType for the types of min and max, nothing will be added

public abstract IBooleanOperation RangeQuery<T>(string[] fields, T? min, T? max, bool minInclusive = true, bool maxInclusive = true) where T : struct

Parameters

fields string[]
min T?
max T?
minInclusive bool
maxInclusive bool

Returns

IBooleanOperation

Type Parameters

T

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.