Skip to content

adding support for enable_position_increments property on ITokenCountProperty #5188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public string Analyzer
set => Self.Analyzer = value;
}

public bool EnablePositionIncrements
{
get => Self.EnablePositionIncrements.GetValueOrDefault(true);
set => Self.EnablePositionIncrements = value;
}

public bool Index
{
get => Self.Index.GetValueOrDefault();
Expand All @@ -27,6 +33,7 @@ public double NullValue
}

string ITokenCountProperty.Analyzer { get; set; }
bool? ITokenCountProperty.EnablePositionIncrements { get; set; }
bool? ITokenCountProperty.Index { get; set; }
double? ITokenCountProperty.NullValue { get; set; }
private ITokenCountProperty Self => this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public interface ITokenCountProperty : IDocValuesProperty
[DataMember(Name ="analyzer")]
string Analyzer { get; set; }

[DataMember(Name ="enable_position_increments")]
bool? EnablePositionIncrements { get; set; }

[DataMember(Name ="index")]
bool? Index { get; set; }

Expand All @@ -33,6 +36,8 @@ public TokenCountProperty() : base(FieldType.TokenCount) { }

public string Analyzer { get; set; }

public bool? EnablePositionIncrements { get; set; }

public bool? Index { get; set; }

public double? NullValue { get; set; }
Expand All @@ -47,13 +52,14 @@ public class TokenCountPropertyDescriptor<T>
public TokenCountPropertyDescriptor() : base(FieldType.TokenCount) { }

string ITokenCountProperty.Analyzer { get; set; }
bool? ITokenCountProperty.EnablePositionIncrements { get; set; }
bool? ITokenCountProperty.Index { get; set; }
double? ITokenCountProperty.NullValue { get; set; }

public TokenCountPropertyDescriptor<T> Analyzer(string analyzer) => Assign(analyzer, (a, v) => a.Analyzer = v);

public TokenCountPropertyDescriptor<T> EnablePositionIncrements(bool? enablePositionIncrements = true) =>
Assign(enablePositionIncrements, (a, v) => a.EnablePositionIncrements = v);
public TokenCountPropertyDescriptor<T> Index(bool? index = true) => Assign(index, (a, v) => a.Index = v);

public TokenCountPropertyDescriptor<T> NullValue(double? nullValue) => Assign(nullValue, (a, v) => a.NullValue = v);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class TokenCountTest
[TokenCount(
Index = false,
Analyzer = "standard",
EnablePositionIncrements = false,
NullValue = 0)]
public int Full { get; set; }

Expand All @@ -28,6 +29,7 @@ public class TokenCountAttributeTests : AttributeTestsBase<TokenCountTest>
{
type = "token_count",
analyzer = "standard",
enable_position_increments = false,
index = false,
null_value = 0.0,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public TokenCountPropertyTests(WritableCluster cluster, EndpointUsage usage) : b
{
type = "token_count",
analyzer = "standard",
enable_position_increments = false,
index = false,
null_value = 0.0
}
Expand All @@ -32,6 +33,7 @@ public TokenCountPropertyTests(WritableCluster cluster, EndpointUsage usage) : b
.TokenCount(s => s
.Name(p => p.Name)
.Analyzer("standard")
.EnablePositionIncrements(false)
.Index(false)
.NullValue(0.0)
);
Expand All @@ -44,6 +46,7 @@ public TokenCountPropertyTests(WritableCluster cluster, EndpointUsage usage) : b
{
Index = false,
Analyzer = "standard",
EnablePositionIncrements = false,
NullValue = 0.0
}
}
Expand Down