Skip to content
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

Refactor Script query to use IScript property #3508

Closed
russcam opened this issue Dec 6, 2018 · 1 comment
Closed

Refactor Script query to use IScript property #3508

russcam opened this issue Dec 6, 2018 · 1 comment
Labels

Comments

@russcam
Copy link
Contributor

russcam commented Dec 6, 2018

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

russcam added a commit that referenced this issue Mar 28, 2019
This commit refactors IScriptQuery to use IScript property
as opposed to individual script properties. Doing so removes
the custom formatter and better aligns with the JSON query DSL structure.

Fixes #3508
russcam added a commit that referenced this issue Apr 4, 2019
* Use IScript on ScriptQuery

This commit refactors IScriptQuery to use IScript property
as opposed to individual script properties. Doing so removes
the custom formatter and better aligns with the JSON query DSL structure.

Fixes #3508

* Use IScript in ScriptScoreFunction

This commit updates ScriptScoreFunction to use IScript
as opposed to IScriptQuery.
@russcam
Copy link
Contributor Author

russcam commented Apr 4, 2019

This is now merged into 7.x in 153bbf3

@russcam russcam closed this as completed Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant