Class QueryParserOptions
- Namespace
- TantivyDotNet
- Assembly
- TantivyDotNet.dll
Settings for parsing query text with Parse(string, QueryParserOptions). Field names are checked when the query runs.
public sealed class QueryParserOptions
- Inheritance
-
QueryParserOptions
- Inherited Members
Examples
var parser = new QueryParserOptions
{
DefaultFields = ["title", "body"],
DefaultOperator = QueryOperator.And,
FieldBoosts = new Dictionary<string, float> { ["title"] = 3f },
FuzzyFields = new Dictionary<string, FuzzyOptions> { ["body"] = new FuzzyOptions(distance: 1) },
Lenient = true,
};
var results = searcher.Search(Query.Parse(userInput, parser));
Properties
- DefaultFields
Fields searched by terms without a
field:prefix. Null (the default) means every indexed text field.
- DefaultOperator
How terms without an explicit
AND/ORare combined. Default Or.
- FieldBoosts
Score multipliers per field, applied to every term matched in that field (multiplied with boosts written in the query, like
title:rust^2). Null (the default) for none.
- FuzzyFields
Text fields whose terms are matched approximately: every term the query text searches in such a field becomes a fuzzy term (Tantivy has no per-term
word~1syntax;~sets a phrase's slop). Phrases stay exact. Null (the default) for none.
- Lenient
Whether to drop the parts of the text that can't be parsed (unbalanced quotes or parentheses, unknown fields, bad ranges) instead of throwing QueryParseException. Use it for text typed by end users. Default false.