elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

RawJsonString encodes script parameter into a string

Open dlukyanov opened this issue 4 months ago • 1 comments

Elastic.Clients.Elasticsearch version: 8.11.0

Elasticsearch version: 8+

.NET runtime version: 6

Operating system version: win10

Description of the problem including expected versus actual behavior: According to https://github.com/elastic/elasticsearch-net/issues/4971#issuecomment-1026691754 should generate raw json in parameters output. However RawJsonString parameter encoded as a string instead of being raw

Steps to reproduce:

    var r = await _elastic.UpdateByQueryAsync(IndexName, c => {
        c.RequestConfiguration(r => r.DisableDirectStreaming()); //capture request body
        c.Query(q => q.Term(q => q.Field("_refid").Value("12345")));
        c.Script(new Script(new InlineScript("ctx._source._access=params.msg._access")
        {
            Params = new Dictionary<string, object>
            {
                { "msg", new RawJsonString(@" {""_access"": [""ACC01""]} ") }
            }
        }));
    });

Expected request generated by library

{
    "query": {"term": {"_refid": {"value": "12345"} }},
    "script": {
        "source": "ctx._source._access=params.msg._access",
        "params": {
            "msg": {
                "_access": ["ACC01"]
            }
        }
    }
}

Actual request generated by library

{
    "query": {"term": {"_refid": {"value": "12345"} }},
    "script": {
        "source": "ctx._source._access=params.msg._access",
        "params": {
            "msg": {
                "json": "{\u0022_access\u0022: [\u0022ACC01\u0022]}"
            }
        }
    }
}

dlukyanov avatar Feb 13 '24 21:02 dlukyanov