1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using Elasticsearch . Net ;
3
4
using Newtonsoft . Json ;
4
5
5
6
namespace Nest
@@ -8,10 +9,26 @@ namespace Nest
8
9
[ JsonConverter ( typeof ( ScriptJsonConverter ) ) ]
9
10
public interface IScript
10
11
{
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>
11
23
[ JsonProperty ( "params" ) ]
12
24
[ JsonConverter ( typeof ( VerbatimDictionaryKeysPreservingNullJsonConverter < string , object > ) ) ]
13
25
Dictionary < string , object > Params { get ; set ; }
14
26
27
+ /// <summary>
28
+ /// Language of script.
29
+ /// </summary>
30
+ /// <param name="lang">language</param>
31
+ /// <returns>this</returns>
15
32
[ JsonProperty ( "lang" ) ]
16
33
string Lang { get ; set ; }
17
34
}
@@ -20,9 +37,17 @@ public abstract class ScriptBase : IScript
20
37
{
21
38
public Dictionary < string , object > Params { get ; set ; }
22
39
40
+ /// <summary>
41
+ /// Language of script.
42
+ /// </summary>
43
+ /// <param name="lang">language</param>
44
+ /// <returns>this</returns>
23
45
public string Lang { get ; set ; }
24
46
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 ) ;
26
51
}
27
52
28
53
public abstract class ScriptDescriptorBase < TDescriptor , TInterface > : DescriptorBase < TDescriptor , TInterface > , IScript
@@ -32,22 +57,56 @@ public abstract class ScriptDescriptorBase<TDescriptor, TInterface> : Descriptor
32
57
Dictionary < string , object > IScript . Params { get ; set ; }
33
58
string IScript . Lang { get ; set ; }
34
59
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>
35
71
public TDescriptor Params ( Dictionary < string , object > scriptParams ) => Assign ( a => a . Params = scriptParams ) ;
36
72
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 > ( ) ) ) ;
39
86
87
+ /// <summary>
88
+ /// Language of script.
89
+ /// </summary>
90
+ /// <param name="lang">language</param>
91
+ /// <returns>this</returns>
40
92
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 ( ) ) ;
41
100
}
42
101
43
102
public class ScriptDescriptor : DescriptorBase < ScriptDescriptor , IDescriptor >
44
103
{
45
104
public IndexedScriptDescriptor Id ( string id ) => new IndexedScriptDescriptor ( id ) ;
46
105
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 " ) ]
48
107
public IndexedScriptDescriptor Indexed ( string id ) => new IndexedScriptDescriptor ( id ) ;
49
108
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" ) ]
51
110
public InlineScriptDescriptor Inline ( string script ) => new InlineScriptDescriptor ( script ) ;
52
111
53
112
public InlineScriptDescriptor Source ( string script ) => new InlineScriptDescriptor ( script ) ;
0 commit comments