Skip to content

Refactor Script query to use IScript property #3508

@russcam

Description

@russcam

The current ScriptQuery implementation includes separate properties at the root level for properties of a script:

[JsonConverter(typeof(ScriptQueryConverter))]
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public interface IScriptQuery : IQuery
{
[JsonProperty("id")]
Id Id { get; set; }
[Obsolete("Use Source. Inline is deprecated and scheduled to be removed in Elasticsearch 7.0")]
[JsonIgnore]
string Inline { get; set; }
[JsonProperty("lang")]
string Lang { get; set; }
[JsonProperty("params")]
[JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter<string, object>))]
Dictionary<string, object> Params { get; set; }
[JsonProperty("source")]
string Source { get; set; }
}

This results in the need to have a custom JsonConverter/serialization component in order to correctly nest these properties in JSON:

{
  "script": {
    "_name": "named_query",
    "boost": 1.1,
    "script": {
      "source": "doc['numberOfCommits'].value > param1",
      "params": {
        "param1": 50
      }
    }
  }
}

These properties should be removed and replaced with an IScript Script {get;set;} property

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