/* 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.Collections.Generic;
using System.Runtime.Serialization;
namespace OpenSearch.Client
{
///
/// Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed
/// before any stemming filters.
///
public interface IStemmerOverrideTokenFilter : ITokenFilter
{
///
/// A list of mapping rules to use.
///
[DataMember(Name ="rules")]
IEnumerable Rules { get; set; }
///
/// A path (either relative to config location, or absolute) to a list of mappings.
///
[DataMember(Name ="rules_path")]
string RulesPath { get; set; }
}
///
public class StemmerOverrideTokenFilter : TokenFilterBase, IStemmerOverrideTokenFilter
{
public StemmerOverrideTokenFilter() : base("stemmer_override") { }
///
public IEnumerable Rules { get; set; }
///
public string RulesPath { get; set; }
}
///
public class StemmerOverrideTokenFilterDescriptor
: TokenFilterDescriptorBase, IStemmerOverrideTokenFilter
{
protected override string Type => "stemmer_override";
IEnumerable IStemmerOverrideTokenFilter.Rules { get; set; }
string IStemmerOverrideTokenFilter.RulesPath { get; set; }
///
public StemmerOverrideTokenFilterDescriptor Rules(IEnumerable rules) => Assign(rules, (a, v) => a.Rules = v);
///
public StemmerOverrideTokenFilterDescriptor Rules(params string[] rules) => Assign(rules, (a, v) => a.Rules = v);
///
public StemmerOverrideTokenFilterDescriptor RulesPath(string path) => Assign(path, (a, v) => a.RulesPath = v);
}
}