| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using Azure.Core; |
| | 7 | | using Azure.Search.Documents.Models; |
| | 8 | |
|
| | 9 | | namespace Azure.Search.Documents |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Options for <see cref="SearchClient.AutocompleteAsync"/> that |
| | 13 | | /// allow specifying autocomplete behaviors, like fuzzy matching. |
| | 14 | | /// </summary> |
| | 15 | | [CodeGenModel("AutocompleteRequest")] |
| | 16 | | [CodeGenSuppress(nameof(AutocompleteOptions), typeof(string), typeof(string))] |
| | 17 | | public partial class AutocompleteOptions |
| | 18 | | { |
| | 19 | | /// <summary> |
| | 20 | | /// Initializes new instance of <see cref="AutocompleteOptions"/> |
| | 21 | | /// </summary> |
| 68 | 22 | | public AutocompleteOptions() |
| | 23 | | { |
| 68 | 24 | | } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// The search text on which to base autocomplete results. |
| | 28 | | /// </summary> |
| | 29 | | [CodeGenMember("search")] |
| 136 | 30 | | internal string SearchText { get; set; } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// The name of the suggester as specified in the suggesters collection |
| | 34 | | /// that's part of the index definition. |
| | 35 | | /// </summary> |
| | 36 | | [CodeGenMember("suggesterName")] |
| 136 | 37 | | internal string SuggesterName { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Specifies the mode for Autocomplete. The default is |
| | 41 | | /// <see cref="AutocompleteMode.OneTerm"/>. Use |
| | 42 | | /// <see cref="AutocompleteMode.TwoTerms"/> to get shingles and |
| | 43 | | /// <see cref="AutocompleteMode.OneTermWithContext"/> to use the |
| | 44 | | /// current context while producing auto-completed terms. |
| | 45 | | /// </summary> |
| | 46 | | [CodeGenMember("autocompleteMode")] |
| 164 | 47 | | public AutocompleteMode? Mode { get; set; } |
| | 48 | |
|
| | 49 | | /// <summary> |
| | 50 | | /// An OData expression that filters the documents used to produce |
| | 51 | | /// completed terms for the Autocomplete result. You can use |
| | 52 | | /// <see cref="SearchFilter.Create(FormattableString)"/> to help |
| | 53 | | /// construct the filter expression. |
| | 54 | | /// </summary> |
| | 55 | | [CodeGenMember("filter")] |
| 116 | 56 | | public string Filter { get; set; } |
| | 57 | |
|
| | 58 | | /// <summary> |
| | 59 | | /// The number of auto-completed terms to retrieve. This must be a |
| | 60 | | /// value between 1 and 100. The default is 5. |
| | 61 | | /// </summary> |
| | 62 | | [CodeGenMember("top")] |
| 104 | 63 | | public int? Size { get; set; } |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// The list of field names to consider when querying for |
| | 67 | | /// auto-completed terms. Target fields must be included in the |
| | 68 | | /// specified suggester. |
| | 69 | | /// </summary> |
| 180 | 70 | | public IList<string> SearchFields { get; internal set; } = new List<string>(); |
| | 71 | |
|
| | 72 | | #pragma warning disable CA1822 // Only (unused but required) setters are static |
| | 73 | | /// <summary> |
| | 74 | | /// Join SearchFields so it can be sent as a comma separated string. |
| | 75 | | /// </summary> |
| | 76 | | [CodeGenMember("searchFields")] |
| | 77 | | internal string SearchFieldsRaw |
| | 78 | | { |
| 42 | 79 | | get => SearchFields.CommaJoin(); |
| 0 | 80 | | set => throw new InvalidOperationException($"Cannot deserialize {nameof(AutocompleteOptions)}."); |
| | 81 | | } |
| | 82 | | #pragma warning restore CA1822 |
| | 83 | |
|
| | 84 | | /// <summary> |
| | 85 | | /// Creates a shallow copy of the AutocompleteOptions. |
| | 86 | | /// </summary> |
| | 87 | | /// <returns>The cloned AutocompleteOptions.</returns> |
| | 88 | | internal AutocompleteOptions Clone() => |
| 32 | 89 | | new AutocompleteOptions |
| 32 | 90 | | { |
| 32 | 91 | | SearchText = SearchText, |
| 32 | 92 | | SuggesterName = SuggesterName, |
| 32 | 93 | | Mode = Mode, |
| 32 | 94 | | Filter = Filter, |
| 32 | 95 | | Size = Size, |
| 32 | 96 | | SearchFields = SearchFields, |
| 32 | 97 | | HighlightPostTag = HighlightPostTag, |
| 32 | 98 | | HighlightPreTag = HighlightPreTag, |
| 32 | 99 | | MinimumCoverage = MinimumCoverage, |
| 32 | 100 | | UseFuzzyMatching = UseFuzzyMatching, |
| 32 | 101 | | }; |
| | 102 | | } |
| | 103 | | } |