Skip to content

StopWords are missing from deserialization of result from Indices.GetSettingsAsync #8614

Closed
@apr-un

Description

@apr-un

Elastic.Clients.Elasticsearch version: 8.18.3 (upgrade from 8.17.1)

Elasticsearch version: 8.17.2

.NET runtime version: net8.0

Operating system version: Linux

Description of the problem including expected versus actual behavior:
I use custom polish stopwords in my project and I need to display all index settings for a managing user.
In version 8.17.1 it was working fine despite using temporary workaround (reading from BackingDictionary marked as Obsolete). In version 8.18.3 deserialized json in place of "stopwords" contains empty object {} instead of array of strings ["a","aby",....]. Other properties are displaying correctly as in earlier version.

Steps to reproduce:

  1. Define some custom stopwords in index settings (simplified):
IndexSettings settings = new IndexSettings();
IndexSettingsAnalysis analysis = new IndexSettingsAnalysis();
string[] stopwords = ["a", "aby", "bo", "co", "i", "z", ];
StopWords sw = new StopWords(stopwords);
TokenFilters tokenFilters = new TokenFilters();
tokenFilters.Add("custom_polish_stop", new StopTokenFilter() {Stopwords = sw, RemoveTrailing = true} );
analysis.TokenFilters = tokenFilters;
settings.Analysis = analysis;
CreateIndexRequest createIndexRequest = new CreateIndexRequest(Indices.Index(indexName));
createIndexRequest.Settings = settings;
var creationStatus = await elasticClient.Indices.CreateAsync(createIndexRequest);
// ...
  1. Read these settings:
GetIndicesSettingsRequest request = new GetIndicesSettingsRequest(Indices.Index(indexName)) {};
IndexSettings settings = null;
var settingsResult = await elasticClient.Indices.GetSettingsAsync(request);
if (settingsResult.IsValidResponse)
{
    settings = settingsResult.Values[indexName].Settings.Index;
}
//....
var returned =  new JsonResult(new {Settings = settings});
  1. Compare returned json with initial values

Expected behavior

I belive that this problem was created when You introduce new type StopWords being an Union (it takes a predefined language name OR array of strings as parameter). Deserializer cannot correctly "guess" which object should be returned and just gives up returning empty object. Funny thing is that in debug I see both values under Stopwords property as Item1 = Turkish (why? I didn't set any) and Item2 = my array of stopwords (see screenshot).
I expect that Stopwords property should contain language name OR array of strings, depending what was set up. Even returning both Item1 and Item2 should be ok (but then language should be set to "custom" ?)

Image

I'm sorry for any errors in code, and if I'm doing something wrong then please explain how to get all index settings correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions