|
1 | | -using System; |
2 | | -using System.Collections.Generic; |
3 | | -using System.Linq; |
4 | | -using System.Text; |
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
5 | 5 | using Newtonsoft.Json; |
6 | 6 | using Newtonsoft.Json.Converters; |
7 | 7 |
|
8 | | -namespace Nest |
9 | | -{ |
10 | | - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] |
11 | | - public class CustomScoreQueryDescriptor<T> : IQuery where T : class |
| 8 | +namespace Nest |
| 9 | +{ |
| 10 | + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] |
| 11 | + public class CustomScoreQueryDescriptor<T> : IQuery where T : class |
12 | 12 | { |
13 | 13 | [JsonProperty(PropertyName = "lang")] |
14 | | - internal string _Lang { get; set; } |
15 | | - |
16 | | - [JsonProperty(PropertyName = "script")] |
17 | | - internal string _Script { get; set; } |
18 | | - |
| 14 | + internal string _Lang { get; set; } |
| 15 | + |
| 16 | + [JsonProperty(PropertyName = "script")] |
| 17 | + internal string _Script { get; set; } |
| 18 | + |
19 | 19 | [JsonProperty(PropertyName = "params")] |
20 | 20 | [JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))] |
21 | | - internal Dictionary<string, object> _Params { get; set; } |
22 | | - |
23 | | - [JsonProperty(PropertyName = "query")] |
24 | | - internal BaseQuery _Query { get; set; } |
25 | | - |
26 | | - internal bool IsConditionless |
27 | | - { |
28 | | - get |
29 | | - { |
30 | | - return this._Query == null || this._Query.IsConditionless; |
31 | | - } |
| 21 | + internal Dictionary<string, object> _Params { get; set; } |
| 22 | + |
| 23 | + [JsonProperty(PropertyName = "query")] |
| 24 | + internal BaseQuery _Query { get; set; } |
| 25 | + |
| 26 | + internal bool IsConditionless |
| 27 | + { |
| 28 | + get |
| 29 | + { |
| 30 | + return this._Query == null || this._Query.IsConditionless; |
| 31 | + } |
32 | 32 | } |
33 | 33 |
|
34 | 34 | public CustomScoreQueryDescriptor<T> Lang(string lang) |
35 | 35 | { |
36 | 36 | this._Lang = lang; |
37 | 37 | return this; |
38 | | - } |
39 | | - |
40 | | - public CustomScoreQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector) |
41 | | - { |
42 | | - querySelector.ThrowIfNull("querySelector"); |
43 | | - var query = new QueryDescriptor<T>(); |
44 | | - var q = querySelector(query); |
45 | | - |
46 | | - this._Query = q; |
47 | | - return this; |
48 | | - } |
49 | | - /// <summary> |
50 | | - /// Scripts are cached for faster execution. If the script has parameters that it needs to take into account, it is preferable to use the same script, and provide parameters to it: |
51 | | - /// </summary> |
52 | | - /// <param name="script"></param> |
53 | | - /// <returns></returns> |
54 | | - public CustomScoreQueryDescriptor<T> Script(string script) |
55 | | - { |
56 | | - script.ThrowIfNull("script"); |
57 | | - this._Script = script; |
58 | | - return this; |
59 | | - } |
60 | | - public CustomScoreQueryDescriptor<T> Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramDictionary) |
61 | | - { |
62 | | - paramDictionary.ThrowIfNull("paramDictionary"); |
63 | | - this._Params = paramDictionary(new FluentDictionary<string, object>()); |
64 | | - return this; |
65 | | - } |
66 | | - } |
67 | | -} |
| 38 | + } |
| 39 | + |
| 40 | + public CustomScoreQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector) |
| 41 | + { |
| 42 | + querySelector.ThrowIfNull("querySelector"); |
| 43 | + var query = new QueryDescriptor<T>(); |
| 44 | + var q = querySelector(query); |
| 45 | + |
| 46 | + this._Query = q; |
| 47 | + return this; |
| 48 | + } |
| 49 | + /// <summary> |
| 50 | + /// Scripts are cached for faster execution. If the script has parameters that it needs to take into account, it is preferable to use the same script, and provide parameters to it: |
| 51 | + /// </summary> |
| 52 | + /// <param name="script"></param> |
| 53 | + /// <returns></returns> |
| 54 | + public CustomScoreQueryDescriptor<T> Script(string script) |
| 55 | + { |
| 56 | + this._Script = script; |
| 57 | + return this; |
| 58 | + } |
| 59 | + public CustomScoreQueryDescriptor<T> Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramDictionary) |
| 60 | + { |
| 61 | + paramDictionary.ThrowIfNull("paramDictionary"); |
| 62 | + this._Params = paramDictionary(new FluentDictionary<string, object>()); |
| 63 | + return this; |
| 64 | + } |
| 65 | + } |
| 66 | +} |
0 commit comments