Add enable_position_increments as a Property on ITokenCountProperty
See original GitHub issueWhat I’m trying to achieve
I am trying to create a ‘CreateIndexDescriptor’ mapping descriptor using NEST Fluent API and I found that the enable_position_increments
is not available on the TokenCountProperty
class or on the TokenCountPropertyDescriptor
(https://github.com/elastic/elasticsearch-net/blob/master/src/Nest/Mapping/Types/Specialized/TokenCount/TokenCountProperty.cs)
For my use case scenario, I need to store the token_count
on a StopWords Analayzer with enable_position_increments
set to false so that in stores the count after the Stopwords analyzer strips out the stop words. As per documentation here, https://www.elastic.co/guide/en/elasticsearch/reference/current/token-count.html , it defaults to true. So i need to explicitly set it to false for my use case.
This is how I set the “token_count” property (portion of the code on the fluent api)
.Properties(ps => ps.Text(
ns => ns.Name(a => a.Value)
.Analyzer("name_analyzer")
.Fields(fs => fs
.Text(ss => ss.Name("StopWords")
.Analyzer("stop_words_analyzer")
.Fields(f => f
.TokenCount(tc => tc
.Name("length")
.Analyzer("standard")))))
which generates this portion as a part of my mapping JSON
"StopWords": {
"type": "text",
"fields": {
"length": {
"type": "token_count",
"analyzer": "standard"
}
},
"analyzer": "stop_words_analyzer"
}
I want to be able to add enable_position_increments
to this JSON via the NEST Fluent API
"StopWords": {
"type": "text",
"fields": {
"length": {
"type": "token_count",
"analyzer": "standard",
"enable_position_increments" : false
}
},
"analyzer": "stop_words_analyzer"
}
The solution I would like
A bool property on ITokenCountProperty
[DataMember(Name ="enable_position_increments")]
bool? EnablePositionIncrements { get; set; }
and the Descriptor implementation for the same
Alternatives considered
I tried using the Custom
method as suggested in guide post (https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/extending-nest-types.html) but that Custom
method seems to be available only on the PropertiesDescriptor
class and not on the IPropertiesDescriptor
interface… It’s not available on the TokenCountPropertiesDescriptor
class
Additional context
Is there any other workaround that I can use to set the enable_position_increments
to false via NEST Client?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
@rdasan You’re welcome. I don’t have exact dates for it yet, but it’ll hopefully be sometime relatively soon in the new year.
I’ve merged #5188, thank yo @rdasan. I’ll backport this and it’ll be included in the 7.11 release.