.net client (8.12) converts params data properties to camelCase but i use PascalCase

Hi all,

I use .net client to index my documents. I use nested field to update arrays and add new objects. I use the PascalCase configuration for Properties.

This is my configuration :

var node = new SingleNodePool(new Uri(options.Value.Url));

			var connectionSettings = new ElasticsearchClientSettings(
				node,
				 sourceSerializer: (defaultSerializer, settings) =>
					new DefaultSourceSerializer(settings, o=> { o.DictionaryKeyPolicy = null;   o.PropertyNamingPolicy = null; })
				)
				.Authentication(new BasicAuthentication(options.Value.UserName, options.Value.Password))
				
				.EnableDebugMode()
				.PrettyJson()
				.DefaultFieldNameInferrer(f => f)
				.RequestTimeout(TimeSpan.FromMinutes(2));
			
			
				

			ElasticClient = new ElasticsearchClient(connectionSettings);


With the script I wrote, I can change part of the directory I have and add new objects to it. The script works but StoredScriptIdConveter passes the data I give to the API as camelCase.

Here is the code :


public async Task UpdateNestedField<TIndexItem>(string indexName, string id, string scriptName, string fieldName, object[] data)
		{
			var res = await ElasticClient.UpdateAsync<TIndexItem,TIndexItem>(indexName, id, request =>
			{
				var storedScript = new StoredScriptId(scriptName);
				storedScript.Params = new Dictionary<string, object>();
				
				var name = fieldName;
				storedScript.Params.Add(name, data);
				var script = new Script(storedScript);
				
				request.Script(script).ScriptedUpsert(true);
				
			});

		}

The request to be sent to the API is below.

{
  "script": {
    "id": "test-class-dictionary-update",
    "params": {
      "DictionaryData": [
        {
          "id": "AB",
          "numberData": 789987
        },
        {
          "id": "YY",
          "numberData": 789789
        }
      ]
    }
  },
  "scripted_upsert": true
}

id and numberData fields are not passed to the script correctly. Therefore new properties are created.

{
  "Id.keyword": [
    "123123"
  ],
  "NumberData": [
    111
  ],
  "Id": [
    "123123"
  ]
},
{
  "id.keyword": [
    "YY"
  ],
  "id": [
    "YY"
  ],
  "numberData": [
    789789
  ]
}

Do you have any idea why this is happening?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.