/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ using System; using System.Linq.Expressions; using System.Runtime.Serialization; namespace OpenSearch.Client { /// /// The fuzzy rule matches terms that are similar to the provided term, within an edit distance defined by Fuzziness. /// If the fuzzy expansion matches more than 128 terms, OpenSearch returns an error. /// [ReadAs(typeof(IntervalsFuzzy))] public interface IIntervalsFuzzy : IIntervalsNoFilter { /// /// Analyzer used to normalize the term. Defaults to the top-level field's analyzer. /// [DataMember(Name = "analyzer")] string Analyzer { get; set; } /// /// Number of beginning characters left unchanged when creating expansions. Defaults to 0. /// [DataMember(Name = "prefix_length")] int? PrefixLength { get; set; } /// /// Indicates whether edits include transpositions of two adjacent characters (ab → ba). Defaults to true. /// [DataMember(Name = "transpositions")] bool? Transpositions { get; set; } /// /// Maximum edit distance allowed for matching. See Fuzziness for valid values and more information. /// Defaults to . /// [DataMember(Name = "fuzziness")] Fuzziness Fuzziness { get; set; } /// /// The term to match. /// [DataMember(Name = "term")] string Term { get; set; } /// /// If specified, then match intervals from this field rather than the top-level field. /// The term is normalized using the search analyzer from this field, /// unless analyzer is specified separately. /// [DataMember(Name = "use_field")] Field UseField { get; set; } } /// public class IntervalsFuzzy : IntervalsNoFilterBase, IIntervalsFuzzy { internal override void WrapInContainer(IIntervalsContainer container) => container.Fuzzy = this; /// public string Analyzer { get; set; } /// public int? PrefixLength { get; set; } /// public bool? Transpositions { get; set; } /// public Fuzziness Fuzziness { get; set; } /// public string Term { get; set; } /// public Field UseField { get; set; } } /// public class IntervalsFuzzyDescriptor : DescriptorBase, IIntervalsFuzzy { string IIntervalsFuzzy.Analyzer { get; set; } int? IIntervalsFuzzy.PrefixLength { get; set; } bool? IIntervalsFuzzy.Transpositions { get; set; } Fuzziness IIntervalsFuzzy.Fuzziness { get; set; } string IIntervalsFuzzy.Term { get; set; } Field IIntervalsFuzzy.UseField { get; set; } /// public IntervalsFuzzyDescriptor Analyzer(string analyzer) => Assign(analyzer, (a, v) => a.Analyzer = v); /// public IntervalsFuzzyDescriptor PrefixLength(int? prefixLength) => Assign(prefixLength, (a, v) => a.PrefixLength = v); /// public IntervalsFuzzyDescriptor Transpositions(bool? transpositions = true) => Assign(transpositions, (a, v) => a.Transpositions = v); /// public IntervalsFuzzyDescriptor Fuzziness(Fuzziness fuzziness) => Assign(fuzziness, (a, v) => a.Fuzziness = v); /// public IntervalsFuzzyDescriptor Term(string term) => Assign(term, (a, v) => a.Term = v); /// public IntervalsFuzzyDescriptor UseField(Expression> objectPath) => Assign(objectPath, (a, v) => a.UseField = v); /// public IntervalsFuzzyDescriptor UseField(Field useField) => Assign(useField, (a, v) => a.UseField = v); } }