diff --git a/src/Nest/Mapping/Types/Core/Text/TextAttribute.cs b/src/Nest/Mapping/Types/Core/Text/TextAttribute.cs index b61e6b2d913..ba4f414ac64 100644 --- a/src/Nest/Mapping/Types/Core/Text/TextAttribute.cs +++ b/src/Nest/Mapping/Types/Core/Text/TextAttribute.cs @@ -19,6 +19,7 @@ public TextAttribute() : base(FieldType.Text) { } IFielddataFrequencyFilter ITextProperty.FielddataFrequencyFilter { get; set; } ITextIndexPrefixes ITextProperty.IndexPrefixes { get; set; } bool? ITextProperty.Index { get; set; } + bool? ITextProperty.IndexPhrases { get; set; } IndexOptions? ITextProperty.IndexOptions { get; set; } bool? ITextProperty.Norms { get; set; } int? ITextProperty.PositionIncrementGap { get; set; } @@ -26,17 +27,18 @@ public TextAttribute() : base(FieldType.Text) { } string ITextProperty.SearchQuoteAnalyzer { get; set; } TermVectorOption? ITextProperty.TermVector { get; set; } - public string Analyzer { get { return Self.Analyzer; } set { Self.Analyzer = value; } } - public double Boost { get { return Self.Boost.GetValueOrDefault(); } set { Self.Boost = value; } } - public bool EagerGlobalOrdinals { get { return Self.EagerGlobalOrdinals.GetValueOrDefault(); } set { Self.EagerGlobalOrdinals = value; } } - public bool Fielddata { get { return Self.Fielddata.GetValueOrDefault(); } set { Self.Fielddata = value; } } - public bool Index { get { return Self.Index.GetValueOrDefault(); } set { Self.Index = value; } } - public IndexOptions IndexOptions { get { return Self.IndexOptions.GetValueOrDefault(); } set { Self.IndexOptions = value; } } - public int PositionIncrementGap { get { return Self.PositionIncrementGap.GetValueOrDefault(); } set { Self.PositionIncrementGap = value; } } - public string SearchAnalyzer { get { return Self.SearchAnalyzer; } set { Self.SearchAnalyzer = value; } } - public string SearchQuoteAnalyzer { get { return Self.SearchQuoteAnalyzer; } set { Self.SearchQuoteAnalyzer = value; } } - public bool Norms { get { return Self.Norms.GetValueOrDefault(true); } set { Self.Norms = value; } } - public TermVectorOption TermVector { get { return Self.TermVector.GetValueOrDefault(); } set { Self.TermVector = value; } } + public string Analyzer { get => Self.Analyzer; set => Self.Analyzer = value; } + public double Boost { get => Self.Boost.GetValueOrDefault(); set => Self.Boost = value; } + public bool EagerGlobalOrdinals { get => Self.EagerGlobalOrdinals.GetValueOrDefault(); set => Self.EagerGlobalOrdinals = value; } + public bool Fielddata { get => Self.Fielddata.GetValueOrDefault(); set => Self.Fielddata = value; } + public bool Index { get => Self.Index.GetValueOrDefault(); set => Self.Index = value; } + public bool IndexPhrases { get => Self.Index.GetValueOrDefault(); set => Self.Index = value; } + public IndexOptions IndexOptions { get => Self.IndexOptions.GetValueOrDefault(); set => Self.IndexOptions = value; } + public int PositionIncrementGap { get => Self.PositionIncrementGap.GetValueOrDefault(); set => Self.PositionIncrementGap = value; } + public string SearchAnalyzer { get => Self.SearchAnalyzer; set => Self.SearchAnalyzer = value; } + public string SearchQuoteAnalyzer { get => Self.SearchQuoteAnalyzer; set => Self.SearchQuoteAnalyzer = value; } + public bool Norms { get => Self.Norms.GetValueOrDefault(true); set => Self.Norms = value; } + public TermVectorOption TermVector { get => Self.TermVector.GetValueOrDefault(); set => Self.TermVector = value; } } } diff --git a/src/Nest/Mapping/Types/Core/Text/TextProperty.cs b/src/Nest/Mapping/Types/Core/Text/TextProperty.cs index bfd6bca684e..73f512d9ac4 100644 --- a/src/Nest/Mapping/Types/Core/Text/TextProperty.cs +++ b/src/Nest/Mapping/Types/Core/Text/TextProperty.cs @@ -34,6 +34,9 @@ public interface ITextProperty : ICoreProperty [JsonProperty("index")] bool? Index { get; set; } + [JsonProperty("index_phrases")] + bool? IndexPhrases { get; set; } + [JsonProperty("index_options")] IndexOptions? IndexOptions { get; set; } @@ -58,6 +61,7 @@ public TextProperty() : base(FieldType.Text) { } public IFielddataFrequencyFilter FielddataFrequencyFilter { get; set; } public ITextIndexPrefixes IndexPrefixes { get; set; } public bool? Index { get; set; } + public bool? IndexPhrases { get; set; } public IndexOptions? IndexOptions { get; set; } public bool? Norms { get; set; } public int? PositionIncrementGap { get; set; } @@ -78,6 +82,7 @@ public class TextPropertyDescriptor IFielddataFrequencyFilter ITextProperty.FielddataFrequencyFilter { get; set; } ITextIndexPrefixes ITextProperty.IndexPrefixes { get; set; } bool? ITextProperty.Index { get; set; } + bool? ITextProperty.IndexPhrases { get; set; } IndexOptions? ITextProperty.IndexOptions { get; set; } bool? ITextProperty.Norms { get; set; } int? ITextProperty.PositionIncrementGap { get; set; } @@ -96,6 +101,7 @@ public TextPropertyDescriptor FielddataFrequencyFilter(Func IndexPrefixes(Func selector) => Assign(a => a.IndexPrefixes = selector?.Invoke(new TextIndexPrefixesDescriptor())); public TextPropertyDescriptor Index(bool? index = true) => Assign(a => a.Index = index); + public TextPropertyDescriptor IndexPhrases(bool? indexPhrases = true) => Assign(a => a.IndexPhrases = indexPhrases); public TextPropertyDescriptor IndexOptions(IndexOptions? indexOptions) => Assign(a => a.IndexOptions = indexOptions); public TextPropertyDescriptor Norms(bool? enabled = true) => Assign(a => a.Norms = enabled); public TextPropertyDescriptor PositionIncrementGap(int? positionIncrementGap) => Assign(a => a.PositionIncrementGap = positionIncrementGap); diff --git a/src/Tests/Tests.Configuration/tests.default.yaml b/src/Tests/Tests.Configuration/tests.default.yaml index af781e2fe08..d5070e54ecd 100644 --- a/src/Tests/Tests.Configuration/tests.default.yaml +++ b/src/Tests/Tests.Configuration/tests.default.yaml @@ -5,7 +5,7 @@ # tracked by git). # mode either u (unit test), i (integration test) or m (mixed mode) -mode: u +mode: m # the elasticsearch version that should be started # Can be a snapshot version of sonatype or "latest" to get the latest snapshot of sonatype elasticsearch_version: 6.4.1 diff --git a/src/Tests/Tests/Mapping/Types/Core/Text/TextPropertyTests.cs b/src/Tests/Tests/Mapping/Types/Core/Text/TextPropertyTests.cs index 27c7e4438ff..f1c828eab9a 100644 --- a/src/Tests/Tests/Mapping/Types/Core/Text/TextPropertyTests.cs +++ b/src/Tests/Tests/Mapping/Types/Core/Text/TextPropertyTests.cs @@ -7,7 +7,84 @@ namespace Tests.Mapping.Types.Core.Text { + + [SkipVersion("<6.4.0", "index_phrases is a new feature")] + public class TextPropertyIndexPhrasesTests : PropertyTestsBase + { + public TextPropertyIndexPhrasesTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override object ExpectJson => new + { + properties = new + { + name = new + { + type = "text", + index_phrases = true + } + } + }; + + + protected override Func, IPromise> FluentProperties => f => f + .Text(s => s + .Name(p => p.Name) + .IndexPhrases() + ); + + + protected override IProperties InitializerProperties => new Properties + { + { "name", new TextProperty { IndexPhrases = true } } + }; + } + [SkipVersion("<6.3.0", "index_prefixes is a new feature")] + public class TextPropertyIndexPrefixesTests : PropertyTestsBase + { + public TextPropertyIndexPrefixesTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override object ExpectJson => new + { + properties = new + { + name = new + { + type = "text", + index_prefixes = new + { + min_chars = 1, + max_chars = 10 + } + } + } + }; + + + protected override Func, IPromise> FluentProperties => f => f + .Text(s => s + .Name(p => p.Name) + .IndexPrefixes(i => i + .MinCharacters(1) + .MaxCharacters(10) + ) + ); + + + protected override IProperties InitializerProperties => new Properties + { + { "name", new TextProperty + { + IndexPrefixes = new TextIndexPrefixes + { + MinCharacters = 1, + MaxCharacters = 10 + } + } + } + }; + } + public class TextPropertyTests : PropertyTestsBase { public TextPropertyTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }