11using System ;
22using System . Collections . Generic ;
3+ using Elasticsearch . Net ;
34using Newtonsoft . Json ;
45
56namespace Nest
@@ -8,10 +9,26 @@ namespace Nest
89 [ JsonConverter ( typeof ( ScriptJsonConverter ) ) ]
910 public interface IScript
1011 {
12+ /// <summary>
13+ /// Scripts are compiled and cached for faster execution.
14+ /// If the same script can be used, just with different parameters provided,
15+ /// it is preferable to use the ability to pass parameters to the script itself.
16+ /// </summary>
17+ /// <example>
18+ /// script: "doc['num1'].value > param1"
19+ /// param: "param1" = 5
20+ /// </example>
21+ /// <param name="paramsDictionary">param</param>
22+ /// <returns>this</returns>
1123 [ JsonProperty ( "params" ) ]
1224 [ JsonConverter ( typeof ( VerbatimDictionaryKeysPreservingNullJsonConverter < string , object > ) ) ]
1325 Dictionary < string , object > Params { get ; set ; }
1426
27+ /// <summary>
28+ /// Language of script.
29+ /// </summary>
30+ /// <param name="lang">language</param>
31+ /// <returns>this</returns>
1532 [ JsonProperty ( "lang" ) ]
1633 string Lang { get ; set ; }
1734 }
@@ -20,9 +37,17 @@ public abstract class ScriptBase : IScript
2037 {
2138 public Dictionary < string , object > Params { get ; set ; }
2239
40+ /// <summary>
41+ /// Language of script.
42+ /// </summary>
43+ /// <param name="lang">language</param>
44+ /// <returns>this</returns>
2345 public string Lang { get ; set ; }
2446
25- public static implicit operator ScriptBase ( string inline ) => new InlineScript ( inline ) ;
47+ /// <summary>
48+ /// Implicit conversion from <see cref="string"/> to <see cref="InlineScript"/>
49+ /// </summary>
50+ public static implicit operator ScriptBase ( string script ) => new InlineScript ( script ) ;
2651 }
2752
2853 public abstract class ScriptDescriptorBase < TDescriptor , TInterface > : DescriptorBase < TDescriptor , TInterface > , IScript
@@ -32,22 +57,56 @@ public abstract class ScriptDescriptorBase<TDescriptor, TInterface> : Descriptor
3257 Dictionary < string , object > IScript . Params { get ; set ; }
3358 string IScript . Lang { get ; set ; }
3459
60+ /// <summary>
61+ /// Scripts are compiled and cached for faster execution.
62+ /// If the same script can be used, just with different parameters provided,
63+ /// it is preferable to use the ability to pass parameters to the script itself.
64+ /// </summary>
65+ /// <example>
66+ /// script: "doc['num1'].value > param1"
67+ /// param: "param1" = 5
68+ /// </example>
69+ /// <param name="paramsDictionary">param</param>
70+ /// <returns>this</returns>
3571 public TDescriptor Params ( Dictionary < string , object > scriptParams ) => Assign ( a => a . Params = scriptParams ) ;
3672
37- public TDescriptor Params ( Func < FluentDictionary < string , object > , FluentDictionary < string , object > > paramsSelector ) =>
38- Assign ( a => a . Params = paramsSelector ? . Invoke ( new FluentDictionary < string , object > ( ) ) ) ;
73+ /// <summary>
74+ /// Scripts are compiled and cached for faster execution.
75+ /// If the same script can be used, just with different parameters provided,
76+ /// it is preferable to use the ability to pass parameters to the script itself.
77+ /// </summary>
78+ /// <example>
79+ /// script: "doc['num1'].value > param1"
80+ /// param: "param1" = 5
81+ /// </example>
82+ /// <param name="paramsDictionary">param</param>
83+ /// <returns>this</returns>
84+ public TDescriptor Params ( Func < FluentDictionary < string , object > , FluentDictionary < string , object > > paramsDictionary ) =>
85+ Assign ( a => a . Params = paramsDictionary ? . Invoke ( new FluentDictionary < string , object > ( ) ) ) ;
3986
87+ /// <summary>
88+ /// Language of script.
89+ /// </summary>
90+ /// <param name="lang">language</param>
91+ /// <returns>this</returns>
4092 public TDescriptor Lang ( string lang ) => Assign ( a => a . Lang = lang ) ;
93+
94+ /// <summary>
95+ /// Language of script.
96+ /// </summary>
97+ /// <param name="lang">language</param>
98+ /// <returns>this</returns>
99+ public TDescriptor Lang ( ScriptLang lang ) => Assign ( a => a . Lang = lang . GetStringValue ( ) ) ;
41100 }
42101
43102 public class ScriptDescriptor : DescriptorBase < ScriptDescriptor , IDescriptor >
44103 {
45104 public IndexedScriptDescriptor Id ( string id ) => new IndexedScriptDescriptor ( id ) ;
46105
47- [ Obsolete ( "Indexed() sets a property named id, this is confusing and thats why we intent to remove this in NEST 7.x please use Id() " ) ]
106+ [ Obsolete ( "Use Id(). Indexed() sets a property named id, which is confusing. Will be removed in the next major version " ) ]
48107 public IndexedScriptDescriptor Indexed ( string id ) => new IndexedScriptDescriptor ( id ) ;
49108
50- [ Obsolete ( "Inline is being deprecated for Source and will be removed in Elasticsearch 7.0" ) ]
109+ [ Obsolete ( "Use Source(). Inline() is deprecated and scheduled to be removed in Elasticsearch 7.0" ) ]
51110 public InlineScriptDescriptor Inline ( string script ) => new InlineScriptDescriptor ( script ) ;
52111
53112 public InlineScriptDescriptor Source ( string script ) => new InlineScriptDescriptor ( script ) ;
0 commit comments