question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add enable_position_increments as a Property on ITokenCountProperty

See original GitHub issue

What 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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
stevejgordoncommented, Dec 17, 2020

@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.

1reaction
stevejgordoncommented, Dec 17, 2020

I’ve merged #5188, thank yo @rdasan. I’ll backport this and it’ll be included in the 7.11 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elasticsearch.Net and NEST - Breaking changes
Many of the *Descriptor fluent methods accepted a value type as a parameter to set a property on a request. These parameter types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found