-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
6.0 Script changes #2951
6.0 Script changes #2951
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,37 @@ | ||
using System.Collections.Generic; | ||
using Elasticsearch.Net; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json; | ||
|
||
namespace Nest | ||
{ | ||
[JsonObject(MemberSerialization = MemberSerialization.OptIn)] | ||
[JsonConverter(typeof(ReadAsTypeJsonConverter<StoredScript>))] | ||
public interface IStoredScript | ||
{ | ||
[JsonProperty("lang")] | ||
string Lang { get; set; } | ||
|
||
[JsonProperty("source")] | ||
string Source { get; set; } | ||
} | ||
public class StoredScript : IStoredScript | ||
{ | ||
[JsonProperty("lang")] | ||
string IStoredScript.Lang { get; set; } | ||
[JsonProperty("source")] | ||
string IStoredScript.Source { get; set; } | ||
|
||
//used for deserialization | ||
internal StoredScript() { } | ||
|
||
protected StoredScript(string lang, string source) | ||
protected StoredScript(string source) | ||
{ | ||
((IStoredScript) this).Lang = lang; | ||
((IStoredScript) this).Source = source; | ||
} | ||
} | ||
|
||
public class PainlessScript : StoredScript | ||
{ | ||
private static readonly string Lang = ScriptLang.Painless.GetStringValue(); | ||
public PainlessScript(string source) : base(Lang, source) { } | ||
} | ||
public class GroovyScript : StoredScript | ||
{ | ||
private static readonly string Lang = ScriptLang.Groovy.GetStringValue(); | ||
public GroovyScript(string source) : base(Lang, source) { } | ||
} | ||
public class JavaScriptScript : StoredScript | ||
{ | ||
private static readonly string Lang = ScriptLang.JS.GetStringValue(); | ||
public JavaScriptScript(string source) : base(Lang, source) { } | ||
} | ||
public class PythonScript : StoredScript | ||
{ | ||
private static readonly string Lang = ScriptLang.Python.GetStringValue(); | ||
public PythonScript(string source) : base(Lang, source) { } | ||
} | ||
public class LuceneExpressionScript : StoredScript | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
private static readonly string Lang = ScriptLang.Expression.GetStringValue(); | ||
public LuceneExpressionScript(string source) : base(Lang, source) { } | ||
} | ||
public class MustacheScript : StoredScript | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
private static readonly string Lang = ScriptLang.Mustache.GetStringValue(); | ||
public MustacheScript(string source) : base(Lang, source) { } | ||
public PainlessScript(string source) : base(source) { } | ||
} | ||
|
||
public class StoredScriptDescriptor : DescriptorBase<StoredScriptDescriptor, IStoredScript>, IStoredScript | ||
{ | ||
string IStoredScript.Lang { get; set; } | ||
string IStoredScript.Source { get; set; } | ||
|
||
public StoredScriptDescriptor Lang(string lang) => Assign(a => a.Lang = lang); | ||
|
||
public StoredScriptDescriptor Source(string source) => Assign(a => a.Source = source); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,5 @@ public PutScriptDescriptor Script(Func<StoredScriptDescriptor, IStoredScript> se | |
Assign(a => a.Script = selector?.Invoke(new StoredScriptDescriptor())); | ||
|
||
public PutScriptDescriptor Painless(string source) => Assign(a => a.Script = new PainlessScript(source)); | ||
public PutScriptDescriptor Groovy(string source) => Assign(a => a.Script = new GroovyScript(source)); | ||
public PutScriptDescriptor JavaScript(string source) => Assign(a => a.Script = new JavaScriptScript(source)); | ||
public PutScriptDescriptor Python(string source) => Assign(a => a.Script = new PythonScript(source)); | ||
public PutScriptDescriptor LuceneExpression(string source) => Assign(a => a.Script = new LuceneExpressionScript(source)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep |
||
public PutScriptDescriptor Mustache(string source) => Assign(a => a.Script = new MustacheScript(source)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still specify lang as part of the body, its just no longer part of the path in the url:
https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/script/StoredScriptSource.java#L157