Skip to content

RawJsonString encodes script parameter into a string #8037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dlukyanov opened this issue Feb 13, 2024 · 1 comment · Fixed by #8051
Closed

RawJsonString encodes script parameter into a string #8037

dlukyanov opened this issue Feb 13, 2024 · 1 comment · Fixed by #8051
Labels
8.x Relates to a 8.x client version Area: Client Category: Bug

Comments

@dlukyanov
Copy link

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 #4971 (comment) 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 dlukyanov added the 8.x Relates to a 8.x client version label Feb 13, 2024
@flobernd flobernd added the bug label Feb 14, 2024
@flobernd
Copy link
Member

Hi @dlukyanov, thanks for reporting! From a first glance, it seems we forgot to annotate the RawJsonString to use the RawJsonConverter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.x Relates to a 8.x client version Area: Client Category: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants