Table of Contents

Method Search

Namespace
TantivyDotNet
Assembly
TantivyDotNet.dll

Search(string, int, int, IEnumerable<string>?)

Parses query with Tantivy's query language and returns the best-scoring documents. Shorthand for Search(Query.Parse(query, defaultFields), limit, offset).

public SearchResults Search(string query, int limit = 10, int offset = 0, IEnumerable<string>? defaultFields = null)

Parameters

query string

For example body:mice AND year:[1930 TO 1940], "exact phrase", title:rust -java. Terms without a field: prefix search defaultFields. Terms are combined with OR by default.

limit int

Maximum number of hits to return. 0 returns no hits but still computes TotalCount.

offset int

Number of top hits to skip, for paging.

defaultFields IEnumerable<string>

Fields searched by unprefixed terms. Null means every indexed text field.

Returns

SearchResults

Exceptions

QueryParseException

The query is malformed or references an unknown field.

Search(string, SearchOptions)

Parses query with Tantivy's query language (unprefixed terms search every indexed text field) and runs it with options. To choose the default fields, use Search(Query, SearchOptions) with Parse(string, QueryParserOptions).

public SearchResults Search(string query, SearchOptions options)

Parameters

query string

The query text; see Search(string, int, int, IEnumerable<string>?).

options SearchOptions

Paging, ordering, snippets and facets.

Returns

SearchResults

Exceptions

QueryParseException

The query is malformed or references an unknown field.

TantivyException

An option doesn't fit the schema; see Search(Query, SearchOptions).

Search(Query, int, int)

Runs a query built in code and returns the best-scoring documents.

public SearchResults Search(Query query, int limit = 10, int offset = 0)

Parameters

query Query

The query; see Query.

limit int

Maximum number of hits to return. 0 returns no hits but still computes TotalCount.

offset int

Number of top hits to skip, for paging.

Returns

SearchResults

Exceptions

TantivyException

A field doesn't exist or doesn't fit the query (for example a phrase on a numeric field), or a ParsedQuery inside the query is malformed (QueryParseException).

Search(Query, SearchOptions)

Runs a query built in code with paging, ordering, snippets and facets.

public SearchResults Search(Query query, SearchOptions options)

Parameters

query Query

The query; see Query.

options SearchOptions

Paging, ordering, snippets and facets.

Returns

SearchResults

Exceptions

TantivyException

A field doesn't exist or doesn't fit the query (for example a phrase on a numeric field); the sort field isn't a fast field of a sortable type; a snippet field isn't a stored text field; a facet request names a non-facet field or the same field twice; or a ParsedQuery inside the query is malformed (QueryParseException).