|
4 | 4 |
|
5 | 5 | namespace Nest |
6 | 6 | { |
| 7 | + /// <summary> |
| 8 | + /// Checks each suggestion against the specified query to prune suggestions |
| 9 | + /// for which no matching docs exist in the index. |
| 10 | + /// </summary> |
7 | 11 | [JsonObject(MemberSerialization = MemberSerialization.OptIn)] |
8 | 12 | [JsonConverter(typeof(ReadAsTypeJsonConverter<PhraseSuggestCollate>))] |
9 | 13 | public interface IPhraseSuggestCollate |
10 | 14 | { |
11 | | - [JsonProperty(PropertyName = "query")] |
| 15 | + /// <summary> |
| 16 | + /// The collate query to run. |
| 17 | + /// </summary> |
| 18 | + /// <remarks> |
| 19 | + /// Query parameters should be specified using <see cref="Params"/> |
| 20 | + /// </remarks> |
| 21 | + [JsonProperty("query")] |
12 | 22 | IScript Query { get; set; } |
13 | 23 |
|
14 | | - [JsonProperty(PropertyName = "prune")] |
| 24 | + /// <summary> |
| 25 | + /// Controls if all phrase suggestions will be returned. When set to <c>true</c>, the suggestions will have |
| 26 | + /// an additional option collate_match, which will be <c>true</c> if matching documents for the phrase was found, |
| 27 | + /// <c>false</c> otherwise. The default value for <see cref="Prune"/> is <c>false</c>. |
| 28 | + /// </summary> |
| 29 | + [JsonProperty("prune")] |
15 | 30 | bool? Prune { get; set; } |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// The parameters for the query. the suggestion value will be added to the variables you specify. |
| 34 | + /// </summary> |
| 35 | + [JsonProperty("params")] |
| 36 | + IDictionary<string, object> Params { get; set; } |
16 | 37 | } |
17 | 38 |
|
| 39 | + /// <inheritdoc /> |
18 | 40 | public class PhraseSuggestCollate : IPhraseSuggestCollate |
19 | 41 | { |
20 | | - public IScript Query { get; set; } |
| 42 | + private IScript _query; |
21 | 43 |
|
| 44 | + /// <inheritdoc /> |
| 45 | + public IScript Query |
| 46 | + { |
| 47 | + get => _query; |
| 48 | + set |
| 49 | + { |
| 50 | + _query = value; |
| 51 | + if (_query != null) Params = _query.Params; |
| 52 | + } |
| 53 | + } |
22 | 54 |
|
| 55 | + /// <inheritdoc /> |
23 | 56 | public bool? Prune { get; set; } |
| 57 | + |
| 58 | + /// <inheritdoc /> |
| 59 | + public IDictionary<string, object> Params { get; set; } |
24 | 60 | } |
25 | 61 |
|
26 | 62 | public class PhraseSuggestCollateDescriptor<T> : DescriptorBase<PhraseSuggestCollateDescriptor<T>, IPhraseSuggestCollate>, IPhraseSuggestCollate |
27 | 63 | where T : class |
28 | 64 | { |
29 | 65 | IScript IPhraseSuggestCollate.Query { get; set; } |
30 | | - |
| 66 | + IDictionary<string, object> IPhraseSuggestCollate.Params { get; set; } |
31 | 67 | bool? IPhraseSuggestCollate.Prune { get; set; } |
32 | | - |
| 68 | + /// <summary> |
| 69 | + /// The collate query to run. |
| 70 | + /// </summary> |
| 71 | + /// <remarks> |
| 72 | + /// Query parameters should be specified using <see cref="Params(IDictionary<string, object>)"/> or |
| 73 | + /// Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>>) |
| 74 | + /// </remarks> |
33 | 75 | public PhraseSuggestCollateDescriptor<T> Query(string script) => Assign(a => a.Query = (InlineScript)script); |
34 | 76 |
|
| 77 | + /// <summary> |
| 78 | + /// The collate query to run. |
| 79 | + /// </summary> |
| 80 | + /// <remarks> |
| 81 | + /// Query parameters should be specified using <see cref="Params(IDictionary<string, object>)"/> or |
| 82 | + /// Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>>) |
| 83 | + /// </remarks> |
35 | 84 | public PhraseSuggestCollateDescriptor<T> Query(Func<ScriptDescriptor, IScript> scriptSelector) => |
36 | 85 | Assign(a => a.Query = scriptSelector?.Invoke(new ScriptDescriptor())); |
37 | 86 |
|
| 87 | + /// <summary> |
| 88 | + /// Controls if all phrase suggestions will be returned. When set to <c>true</c>, the suggestions will have |
| 89 | + /// an additional option collate_match, which will be <c>true</c> if matching documents for the phrase was found, |
| 90 | + /// <c>false</c> otherwise. The default value for <see cref="Prune"/> is <c>false</c>. |
| 91 | + /// </summary> |
38 | 92 | public PhraseSuggestCollateDescriptor<T> Prune(bool? prune = true) => Assign(a => a.Prune = prune); |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// The parameters for the query. the suggestion value will be added to the variables you specify. |
| 96 | + /// </summary> |
| 97 | + public PhraseSuggestCollateDescriptor<T> Params(IDictionary<string, object> paramsDictionary) => Assign(a => a.Params = paramsDictionary); |
| 98 | + |
| 99 | + /// <summary> |
| 100 | + /// The parameters for the query. the suggestion value will be added to the variables you specify. |
| 101 | + /// </summary> |
| 102 | + public PhraseSuggestCollateDescriptor<T> Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramsDictionary) => |
| 103 | + Assign(a => a.Params = paramsDictionary(new FluentDictionary<string, object>())); |
39 | 104 | } |
40 | 105 | } |
0 commit comments