Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/Nest/Mapping/Types/Core/Text/TextAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ 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; }
string ITextProperty.SearchAnalyzer { get; set; }
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; }

}
}
6 changes: 6 additions & 0 deletions src/Nest/Mapping/Types/Core/Text/TextProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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; }
Expand All @@ -78,6 +82,7 @@ public class TextPropertyDescriptor<T>
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; }
Expand All @@ -96,6 +101,7 @@ public TextPropertyDescriptor<T> FielddataFrequencyFilter(Func<FielddataFrequenc
public TextPropertyDescriptor<T> IndexPrefixes(Func<TextIndexPrefixesDescriptor, ITextIndexPrefixes> selector) =>
Assign(a => a.IndexPrefixes = selector?.Invoke(new TextIndexPrefixesDescriptor()));
public TextPropertyDescriptor<T> Index(bool? index = true) => Assign(a => a.Index = index);
public TextPropertyDescriptor<T> IndexPhrases(bool? indexPhrases = true) => Assign(a => a.IndexPhrases = indexPhrases);
public TextPropertyDescriptor<T> IndexOptions(IndexOptions? indexOptions) => Assign(a => a.IndexOptions = indexOptions);
public TextPropertyDescriptor<T> Norms(bool? enabled = true) => Assign(a => a.Norms = enabled);
public TextPropertyDescriptor<T> PositionIncrementGap(int? positionIncrementGap) => Assign(a => a.PositionIncrementGap = positionIncrementGap);
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Tests.Configuration/tests.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
77 changes: 77 additions & 0 deletions src/Tests/Tests/Mapping/Types/Core/Text/TextPropertyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropertiesDescriptor<Project>, IPromise<IProperties>> 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<PropertiesDescriptor<Project>, IPromise<IProperties>> 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) { }
Expand Down