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
querystringFor example
body:mice AND year:[1930 TO 1940],"exact phrase",title:rust -java. Terms without afield:prefix searchdefaultFields. Terms are combined with OR by default.limitintMaximum number of hits to return. 0 returns no hits but still computes TotalCount.
offsetintNumber of top hits to skip, for paging.
defaultFieldsIEnumerable<string>Fields searched by unprefixed terms. Null means every indexed text field.
Returns
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
querystringThe query text; see Search(string, int, int, IEnumerable<string>?).
optionsSearchOptionsPaging, ordering, snippets and facets.
Returns
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
queryQueryThe query; see Query.
limitintMaximum number of hits to return. 0 returns no hits but still computes TotalCount.
offsetintNumber of top hits to skip, for paging.
Returns
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
queryQueryThe query; see Query.
optionsSearchOptionsPaging, ordering, snippets and facets.
Returns
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).