/* 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 { /// /// Matches terms using a wildcard pattern. This pattern can expand to match at most 128 terms. /// If the pattern matches more than 128 terms, OpenSearch returns an error. /// [ReadAs(typeof(IntervalsWildcard))] public interface IIntervalsWildcard : IIntervalsNoFilter { /// /// Analyzer used to normalize the prefix. Defaults to the top-level field's analyzer. /// [DataMember(Name = "analyzer")] string Analyzer { get; set; } /// /// Wildcard pattern used to find matching terms. Supports two wildcard operators: /// ?, which matches any single character /// *, which can match zero or more characters, including an empty one /// Warning: Avoid beginning patterns with * or ?. This can increase the iterations needed to find matching terms and slow search performance. /// [DataMember(Name = "pattern")] string Pattern { get; set; } /// /// If specified, then match intervals from this field rather than the top-level field. /// The prefix is normalized using the search analyzer from this field, unless a separate analyzer is specified. /// [DataMember(Name = "use_field")] Field UseField { get; set; } } /// public class IntervalsWildcard : IntervalsNoFilterBase, IIntervalsWildcard { /// public string Analyzer { get; set; } /// public string Pattern { get; set; } /// public Field UseField { get; set; } internal override void WrapInContainer(IIntervalsContainer container) => container.Wildcard = this; } /// public class IntervalsWildcardDescriptor : DescriptorBase, IIntervalsWildcard { string IIntervalsWildcard.Analyzer { get; set; } string IIntervalsWildcard.Pattern { get; set; } Field IIntervalsWildcard.UseField { get; set; } /// public IntervalsWildcardDescriptor Analyzer(string analyzer) => Assign(analyzer, (a, v) => a.Analyzer = v); /// public IntervalsWildcardDescriptor Pattern(string pattern) => Assign(pattern, (a, v) => a.Pattern = v); /// public IntervalsWildcardDescriptor UseField(Expression> objectPath) => Assign(objectPath, (a, v) => a.UseField = v); /// public IntervalsWildcardDescriptor UseField(Field useField) => Assign(useField, (a, v) => a.UseField = v); } }