示例#1
0
 /// <summary>
 /// Adds a term to the current query, under the covers this will create a `Clause`
 /// to the list of clauses that make up this query.
 ///
 /// The term is used as is, i.e.no tokenization will be performed by this method.
 /// Instead, conversion to a token or token-like string should be done before calling this method.
 /// </summary>
 /// <param name="term">The term to add to the query.</param>
 /// <param name="boost">An optional boost for the term.</param>
 /// <param name="editDistance">The maximum edit distance from the term.</param>
 /// <param name="usePipeline">Set to false to bypass the pipeline.</param>
 /// <param name="wildcard">An optional wildcard.</param>
 /// <param name="presence">The type of presence for this term.</param>
 /// <param name="fields">An optional list of fields to look for the term in.</param>
 /// <returns>The query.</returns>
 public Query AddTerm(
     string term                 = "",
     double boost                = 1,
     int editDistance            = 0,
     bool usePipeline            = true,
     QueryWildcard wildcard      = QueryWildcard.None,
     QueryPresence presence      = QueryPresence.Optional,
     IEnumerable <string>?fields = null)
 => AddClause(new Clause(term, boost, editDistance, usePipeline, wildcard, presence, fields));
示例#2
0
 /// <summary>
 /// Builds a new clause.
 /// </summary>
 /// <param name="term">The term to search for.</param>
 /// <param name="fields">The fields in an index this clause should be matched against.</param>
 /// <param name="boost">Any boost that should be applied when matching this clause.</param>
 /// <param name="editDistance">Whether the term should have fuzzy matching applied, and how fuzzy the match should be.</param>
 /// <param name="usePipeline">Whether the term should be passed through the search pipeline.</param>
 /// <param name="wildcard">Whether the term should have wildcards appended or prepended.</param>
 /// <param name="presence">The terms presence in any matching documents.</param>
 public Clause(
     string term            = "",
     double boost           = 1,
     int editDistance       = 0,
     bool usePipeline       = true,
     QueryWildcard wildcard = QueryWildcard.None,
     QueryPresence presence = QueryPresence.Optional,
     params string[] fields)
     : this(
         term,
         boost,
         editDistance,
         usePipeline,
         wildcard,
         presence,
         (IEnumerable <string>)fields)
 {
 }
示例#3
0
 /// <summary>
 /// Builds a new clause.
 /// </summary>
 /// <param name="term">The term to search for.</param>
 /// <param name="boost">Any boost that should be applied when matching this clause.</param>
 /// <param name="editDistance">Whether the term should have fuzzy matching applied, and how fuzzy the match should be.</param>
 /// <param name="usePipeline">Whether the term should be passed through the search pipeline.</param>
 /// <param name="wildcard">Whether the term should have wildcards appended or prepended.</param>
 /// <param name="presence">The terms presence in any matching documents.</param>
 /// <param name="fields">The fields in an index this clause should be matched against.</param>
 public Clause(
     string term                 = "",
     double boost                = 1,
     int editDistance            = 0,
     bool usePipeline            = true,
     QueryWildcard wildcard      = QueryWildcard.None,
     QueryPresence presence      = QueryPresence.Optional,
     IEnumerable <string>?fields = null !)
 {
     Fields       = fields ?? Array.Empty <string>();
     Boost        = boost;
     EditDistance = editDistance;
     UsePipeline  = usePipeline;
     Wildcard     = wildcard;
     Presence     = presence;
     Term         = ((wildcard & QueryWildcard.Leading) != 0 && (term[0] != Query.Wildcard) ? "*" : "") +
                    term +
                    ((wildcard & QueryWildcard.Trailing) != 0 && (term[term.Length - 1] != Query.Wildcard) ? "*" : "");
 }