/// <summary>
 /// Creates a new simple Field with required arguments.
 /// </summary>
 /// <param name="name">The name of the simple field.</param>
 /// <param name="dataType">The data type of the simple field. Cannot be a complex type.</param>
 /// <param name="isKey">A value indicating whether the field uniquely
 /// identifies documents in the index. Default is false.</param>
 /// <param name="isRetrievable">A value indicating whether the field can
 /// be returned in a search result. Default is true.</param>
 /// <param name="isSearchable">A value indicating whether the field is
 /// full-text search-able. Default is false.</param>
 /// <param name="isFilterable">A value indicating whether to enable the
 /// field to be referenced in $filter queries. Default is false.</param>
 /// <param name="isSortable">A value indicating whether to enable the
 /// field to be referenced in $orderby expressions. Default is false.</param>
 /// <param name="isFacetable">A value indicating whether to enable the
 /// field to be referenced in facet queries. Default is false.</param>
 /// <param name="analyzerName">The name of the language analyzer to use for
 /// the field. Default is null.</param>
 /// <param name="searchAnalyzerName">The name of the analyzer used at
 /// search time for the field. Default is null.</param>
 /// <param name="indexAnalyzerName">The name of the analyzer used at
 /// indexing time for the field. Default is null.</param>
 /// <param name="synonymMaps">A list of synonym map names that
 /// associates synonym maps with the field. Default is null.</param>
 /// <exception cref="System.ArgumentException">Thrown if <c>dataType</c> is a complex type.</exception>
 public static Field New(
     string name,
     DataType dataType,
     bool isKey                      = false,
     bool isRetrievable              = true,
     bool isSearchable               = false,
     bool isFilterable               = false,
     bool isSortable                 = false,
     bool isFacetable                = false,
     AnalyzerName?analyzerName       = null,
     AnalyzerName?searchAnalyzerName = null,
     AnalyzerName?indexAnalyzerName  = null,
     IList <string> synonymMaps      = null) =>
 new Field(name, dataType)
 {
     IsKey          = isKey,
     IsRetrievable  = isRetrievable,
     IsSearchable   = isSearchable,
     IsFilterable   = isFilterable,
     IsSortable     = isSortable,
     IsFacetable    = isFacetable,
     Analyzer       = analyzerName,
     SearchAnalyzer = searchAnalyzerName,
     IndexAnalyzer  = indexAnalyzerName,
     SynonymMaps    = synonymMaps
 };
Beispiel #2
0
 internal AnalyzeRequest(string text, AnalyzerName?analyzer, TokenizerName?tokenizer, IList <TokenFilterName> tokenFilters, IList <string> charFilters)
 {
     Text         = text;
     Analyzer     = analyzer;
     Tokenizer    = tokenizer;
     TokenFilters = tokenFilters;
     CharFilters  = charFilters;
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the AnalyzeRequest class.
 /// </summary>
 /// <param name="text">The text to break into tokens.</param>
 /// <param name="analyzer">The name of the analyzer to use to break the
 /// given text. If this parameter is not specified, you must specify a
 /// tokenizer instead. The tokenizer and analyzer parameters are
 /// mutually exclusive. Possible values include: 'ar.microsoft',
 /// 'ar.lucene', 'hy.lucene', 'bn.microsoft', 'eu.lucene',
 /// 'bg.microsoft', 'bg.lucene', 'ca.microsoft', 'ca.lucene',
 /// 'zh-Hans.microsoft', 'zh-Hans.lucene', 'zh-Hant.microsoft',
 /// 'zh-Hant.lucene', 'hr.microsoft', 'cs.microsoft', 'cs.lucene',
 /// 'da.microsoft', 'da.lucene', 'nl.microsoft', 'nl.lucene',
 /// 'en.microsoft', 'en.lucene', 'et.microsoft', 'fi.microsoft',
 /// 'fi.lucene', 'fr.microsoft', 'fr.lucene', 'gl.lucene',
 /// 'de.microsoft', 'de.lucene', 'el.microsoft', 'el.lucene',
 /// 'gu.microsoft', 'he.microsoft', 'hi.microsoft', 'hi.lucene',
 /// 'hu.microsoft', 'hu.lucene', 'is.microsoft', 'id.microsoft',
 /// 'id.lucene', 'ga.lucene', 'it.microsoft', 'it.lucene',
 /// 'ja.microsoft', 'ja.lucene', 'kn.microsoft', 'ko.microsoft',
 /// 'ko.lucene', 'lv.microsoft', 'lv.lucene', 'lt.microsoft',
 /// 'ml.microsoft', 'ms.microsoft', 'mr.microsoft', 'nb.microsoft',
 /// 'no.lucene', 'fa.lucene', 'pl.microsoft', 'pl.lucene',
 /// 'pt-BR.microsoft', 'pt-BR.lucene', 'pt-PT.microsoft',
 /// 'pt-PT.lucene', 'pa.microsoft', 'ro.microsoft', 'ro.lucene',
 /// 'ru.microsoft', 'ru.lucene', 'sr-cyrillic.microsoft',
 /// 'sr-latin.microsoft', 'sk.microsoft', 'sl.microsoft',
 /// 'es.microsoft', 'es.lucene', 'sv.microsoft', 'sv.lucene',
 /// 'ta.microsoft', 'te.microsoft', 'th.microsoft', 'th.lucene',
 /// 'tr.microsoft', 'tr.lucene', 'uk.microsoft', 'ur.microsoft',
 /// 'vi.microsoft', 'standard.lucene', 'standardasciifolding.lucene',
 /// 'keyword', 'pattern', 'simple', 'stop', 'whitespace'</param>
 /// <param name="tokenizer">The name of the tokenizer to use to break
 /// the given text. If this parameter is not specified, you must
 /// specify an analyzer instead. The tokenizer and analyzer parameters
 /// are mutually exclusive. Possible values include: 'classic',
 /// 'edgeNGram', 'keyword_v2', 'letter', 'lowercase',
 /// 'microsoft_language_tokenizer',
 /// 'microsoft_language_stemming_tokenizer', 'nGram',
 /// 'path_hierarchy_v2', 'pattern', 'standard_v2', 'uax_url_email',
 /// 'whitespace'</param>
 /// <param name="tokenFilters">An optional list of token filters to use
 /// when breaking the given text. This parameter can only be set when
 /// using the tokenizer parameter.</param>
 /// <param name="charFilters">An optional list of character filters to
 /// use when breaking the given text. This parameter can only be set
 /// when using the tokenizer parameter.</param>
 public AnalyzeRequest(string text, AnalyzerName?analyzer = default(AnalyzerName?), TokenizerName?tokenizer = default(TokenizerName?), IList <TokenFilterName> tokenFilters = default(IList <TokenFilterName>), IList <CharFilterName> charFilters = default(IList <CharFilterName>))
 {
     Text         = text;
     Analyzer     = analyzer;
     Tokenizer    = tokenizer;
     TokenFilters = tokenFilters;
     CharFilters  = charFilters;
     CustomInit();
 }
Beispiel #4
0
 internal Field(string name, DataType type, bool?key, bool?retrievable, bool?searchable, bool?filterable, bool?sortable, bool?facetable, AnalyzerName?analyzer, AnalyzerName?searchAnalyzer, AnalyzerName?indexAnalyzer, IList <string> synonymMaps, IList <Field> fields)
 {
     Name           = name;
     Type           = type;
     Key            = key;
     Retrievable    = retrievable;
     Searchable     = searchable;
     Filterable     = filterable;
     Sortable       = sortable;
     Facetable      = facetable;
     Analyzer       = analyzer;
     SearchAnalyzer = searchAnalyzer;
     IndexAnalyzer  = indexAnalyzer;
     SynonymMaps    = synonymMaps;
     Fields         = fields;
 }
 internal SearchField(string name, DataType type, bool?isKey, bool?isRetrievable, bool?isSearchable, bool?isFilterable, bool?isSortable, bool?isFacetable, AnalyzerName?analyzer, AnalyzerName?searchAnalyzer, AnalyzerName?indexAnalyzer, IList <string> synonymMaps, IList <SearchField> fields)
 {
     Name           = name;
     Type           = type;
     IsKey          = isKey;
     IsRetrievable  = isRetrievable;
     IsSearchable   = isSearchable;
     IsFilterable   = isFilterable;
     IsSortable     = isSortable;
     IsFacetable    = isFacetable;
     Analyzer       = analyzer;
     SearchAnalyzer = searchAnalyzer;
     IndexAnalyzer  = indexAnalyzer;
     SynonymMaps    = synonymMaps;
     Fields         = fields;
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the Field class.
 /// </summary>
 /// <param name="name">The name of the field, which must be unique
 /// within the fields collection of the index or parent field.</param>
 /// <param name="type">The data type of the field. Possible values
 /// include: 'Edm.String', 'Edm.Int32', 'Edm.Int64', 'Edm.Double',
 /// 'Edm.Boolean', 'Edm.DateTimeOffset', 'Edm.GeographyPoint',
 /// 'Edm.ComplexType'</param>
 /// <param name="key">A value indicating whether the field uniquely
 /// identifies documents in the index. Exactly one top-level field in
 /// each index must be chosen as the key field and it must be of type
 /// Edm.String. Key fields can be used to look up documents directly
 /// and update or delete specific documents. Default is false for
 /// simple fields and null for complex fields.</param>
 /// <param name="retrievable">A value indicating whether the field can
 /// be returned in a search result. You can disable this option if you
 /// want to use a field (for example, margin) as a filter, sorting, or
 /// scoring mechanism but do not want the field to be visible to the
 /// end user. This property must be true for key fields, and it must be
 /// null for complex fields. This property can be changed on existing
 /// fields. Enabling this property does not cause any increase in index
 /// storage requirements. Default is true for simple fields and null
 /// for complex fields.</param>
 /// <param name="searchable">A value indicating whether the field is
 /// full-text searchable. This means it will undergo analysis such as
 /// word-breaking during indexing. If you set a searchable field to a
 /// value like "sunny day", internally it will be split into the
 /// individual tokens "sunny" and "day". This enables full-text
 /// searches for these terms. Fields of type Edm.String or
 /// Collection(Edm.String) are searchable by default. This property
 /// must be false for simple fields of other non-string data types, and
 /// it must be null for complex fields. Note: searchable fields consume
 /// extra space in your index since Azure Cognitive Search will store
 /// an additional tokenized version of the field value for full-text
 /// searches. If you want to save space in your index and you don't
 /// need a field to be included in searches, set searchable to
 /// false.</param>
 /// <param name="filterable">A value indicating whether to enable the
 /// field to be referenced in $filter queries. filterable differs from
 /// searchable in how strings are handled. Fields of type Edm.String or
 /// Collection(Edm.String) that are filterable do not undergo
 /// word-breaking, so comparisons are for exact matches only. For
 /// example, if you set such a field f to "sunny day", $filter=f eq
 /// 'sunny' will find no matches, but $filter=f eq 'sunny day' will.
 /// This property must be null for complex fields. Default is true for
 /// simple fields and null for complex fields.</param>
 /// <param name="sortable">A value indicating whether to enable the
 /// field to be referenced in $orderby expressions. By default Azure
 /// Cognitive Search sorts results by score, but in many experiences
 /// users will want to sort by fields in the documents. A simple field
 /// can be sortable only if it is single-valued (it has a single value
 /// in the scope of the parent document). Simple collection fields
 /// cannot be sortable, since they are multi-valued. Simple sub-fields
 /// of complex collections are also multi-valued, and therefore cannot
 /// be sortable. This is true whether it's an immediate parent field,
 /// or an ancestor field, that's the complex collection. Complex fields
 /// cannot be sortable and the sortable property must be null for such
 /// fields. The default for sortable is true for single-valued simple
 /// fields, false for multi-valued simple fields, and null for complex
 /// fields.</param>
 /// <param name="facetable">A value indicating whether to enable the
 /// field to be referenced in facet queries. Typically used in a
 /// presentation of search results that includes hit count by category
 /// (for example, search for digital cameras and see hits by brand, by
 /// megapixels, by price, and so on). This property must be null for
 /// complex fields. Fields of type Edm.GeographyPoint or
 /// Collection(Edm.GeographyPoint) cannot be facetable. Default is true
 /// for all other simple fields.</param>
 /// <param name="analyzer">The name of the language analyzer to use for
 /// the field. This option can be used only with searchable fields and
 /// it can't be set together with either searchAnalyzer or
 /// indexAnalyzer. Once the analyzer is chosen, it cannot be changed
 /// for the field. Must be null for complex fields. Possible values
 /// include: 'ar.microsoft', 'ar.lucene', 'hy.lucene', 'bn.microsoft',
 /// 'eu.lucene', 'bg.microsoft', 'bg.lucene', 'ca.microsoft',
 /// 'ca.lucene', 'zh-Hans.microsoft', 'zh-Hans.lucene',
 /// 'zh-Hant.microsoft', 'zh-Hant.lucene', 'hr.microsoft',
 /// 'cs.microsoft', 'cs.lucene', 'da.microsoft', 'da.lucene',
 /// 'nl.microsoft', 'nl.lucene', 'en.microsoft', 'en.lucene',
 /// 'et.microsoft', 'fi.microsoft', 'fi.lucene', 'fr.microsoft',
 /// 'fr.lucene', 'gl.lucene', 'de.microsoft', 'de.lucene',
 /// 'el.microsoft', 'el.lucene', 'gu.microsoft', 'he.microsoft',
 /// 'hi.microsoft', 'hi.lucene', 'hu.microsoft', 'hu.lucene',
 /// 'is.microsoft', 'id.microsoft', 'id.lucene', 'ga.lucene',
 /// 'it.microsoft', 'it.lucene', 'ja.microsoft', 'ja.lucene',
 /// 'kn.microsoft', 'ko.microsoft', 'ko.lucene', 'lv.microsoft',
 /// 'lv.lucene', 'lt.microsoft', 'ml.microsoft', 'ms.microsoft',
 /// 'mr.microsoft', 'nb.microsoft', 'no.lucene', 'fa.lucene',
 /// 'pl.microsoft', 'pl.lucene', 'pt-BR.microsoft', 'pt-BR.lucene',
 /// 'pt-PT.microsoft', 'pt-PT.lucene', 'pa.microsoft', 'ro.microsoft',
 /// 'ro.lucene', 'ru.microsoft', 'ru.lucene', 'sr-cyrillic.microsoft',
 /// 'sr-latin.microsoft', 'sk.microsoft', 'sl.microsoft',
 /// 'es.microsoft', 'es.lucene', 'sv.microsoft', 'sv.lucene',
 /// 'ta.microsoft', 'te.microsoft', 'th.microsoft', 'th.lucene',
 /// 'tr.microsoft', 'tr.lucene', 'uk.microsoft', 'ur.microsoft',
 /// 'vi.microsoft', 'standard.lucene', 'standardasciifolding.lucene',
 /// 'keyword', 'pattern', 'simple', 'stop', 'whitespace'</param>
 /// <param name="searchAnalyzer">The name of the analyzer used at
 /// search time for the field. This option can be used only with
 /// searchable fields. It must be set together with indexAnalyzer and
 /// it cannot be set together with the analyzer option. This analyzer
 /// can be updated on an existing field. Must be null for complex
 /// fields. Possible values include: 'ar.microsoft', 'ar.lucene',
 /// 'hy.lucene', 'bn.microsoft', 'eu.lucene', 'bg.microsoft',
 /// 'bg.lucene', 'ca.microsoft', 'ca.lucene', 'zh-Hans.microsoft',
 /// 'zh-Hans.lucene', 'zh-Hant.microsoft', 'zh-Hant.lucene',
 /// 'hr.microsoft', 'cs.microsoft', 'cs.lucene', 'da.microsoft',
 /// 'da.lucene', 'nl.microsoft', 'nl.lucene', 'en.microsoft',
 /// 'en.lucene', 'et.microsoft', 'fi.microsoft', 'fi.lucene',
 /// 'fr.microsoft', 'fr.lucene', 'gl.lucene', 'de.microsoft',
 /// 'de.lucene', 'el.microsoft', 'el.lucene', 'gu.microsoft',
 /// 'he.microsoft', 'hi.microsoft', 'hi.lucene', 'hu.microsoft',
 /// 'hu.lucene', 'is.microsoft', 'id.microsoft', 'id.lucene',
 /// 'ga.lucene', 'it.microsoft', 'it.lucene', 'ja.microsoft',
 /// 'ja.lucene', 'kn.microsoft', 'ko.microsoft', 'ko.lucene',
 /// 'lv.microsoft', 'lv.lucene', 'lt.microsoft', 'ml.microsoft',
 /// 'ms.microsoft', 'mr.microsoft', 'nb.microsoft', 'no.lucene',
 /// 'fa.lucene', 'pl.microsoft', 'pl.lucene', 'pt-BR.microsoft',
 /// 'pt-BR.lucene', 'pt-PT.microsoft', 'pt-PT.lucene', 'pa.microsoft',
 /// 'ro.microsoft', 'ro.lucene', 'ru.microsoft', 'ru.lucene',
 /// 'sr-cyrillic.microsoft', 'sr-latin.microsoft', 'sk.microsoft',
 /// 'sl.microsoft', 'es.microsoft', 'es.lucene', 'sv.microsoft',
 /// 'sv.lucene', 'ta.microsoft', 'te.microsoft', 'th.microsoft',
 /// 'th.lucene', 'tr.microsoft', 'tr.lucene', 'uk.microsoft',
 /// 'ur.microsoft', 'vi.microsoft', 'standard.lucene',
 /// 'standardasciifolding.lucene', 'keyword', 'pattern', 'simple',
 /// 'stop', 'whitespace'</param>
 /// <param name="indexAnalyzer">The name of the analyzer used at
 /// indexing time for the field. This option can be used only with
 /// searchable fields. It must be set together with searchAnalyzer and
 /// it cannot be set together with the analyzer option. Once the
 /// analyzer is chosen, it cannot be changed for the field. Must be
 /// null for complex fields. Possible values include: 'ar.microsoft',
 /// 'ar.lucene', 'hy.lucene', 'bn.microsoft', 'eu.lucene',
 /// 'bg.microsoft', 'bg.lucene', 'ca.microsoft', 'ca.lucene',
 /// 'zh-Hans.microsoft', 'zh-Hans.lucene', 'zh-Hant.microsoft',
 /// 'zh-Hant.lucene', 'hr.microsoft', 'cs.microsoft', 'cs.lucene',
 /// 'da.microsoft', 'da.lucene', 'nl.microsoft', 'nl.lucene',
 /// 'en.microsoft', 'en.lucene', 'et.microsoft', 'fi.microsoft',
 /// 'fi.lucene', 'fr.microsoft', 'fr.lucene', 'gl.lucene',
 /// 'de.microsoft', 'de.lucene', 'el.microsoft', 'el.lucene',
 /// 'gu.microsoft', 'he.microsoft', 'hi.microsoft', 'hi.lucene',
 /// 'hu.microsoft', 'hu.lucene', 'is.microsoft', 'id.microsoft',
 /// 'id.lucene', 'ga.lucene', 'it.microsoft', 'it.lucene',
 /// 'ja.microsoft', 'ja.lucene', 'kn.microsoft', 'ko.microsoft',
 /// 'ko.lucene', 'lv.microsoft', 'lv.lucene', 'lt.microsoft',
 /// 'ml.microsoft', 'ms.microsoft', 'mr.microsoft', 'nb.microsoft',
 /// 'no.lucene', 'fa.lucene', 'pl.microsoft', 'pl.lucene',
 /// 'pt-BR.microsoft', 'pt-BR.lucene', 'pt-PT.microsoft',
 /// 'pt-PT.lucene', 'pa.microsoft', 'ro.microsoft', 'ro.lucene',
 /// 'ru.microsoft', 'ru.lucene', 'sr-cyrillic.microsoft',
 /// 'sr-latin.microsoft', 'sk.microsoft', 'sl.microsoft',
 /// 'es.microsoft', 'es.lucene', 'sv.microsoft', 'sv.lucene',
 /// 'ta.microsoft', 'te.microsoft', 'th.microsoft', 'th.lucene',
 /// 'tr.microsoft', 'tr.lucene', 'uk.microsoft', 'ur.microsoft',
 /// 'vi.microsoft', 'standard.lucene', 'standardasciifolding.lucene',
 /// 'keyword', 'pattern', 'simple', 'stop', 'whitespace'</param>
 /// <param name="synonymMaps">A list of the names of synonym maps to
 /// associate with this field. This option can be used only with
 /// searchable fields. Currently only one synonym map per field is
 /// supported. Assigning a synonym map to a field ensures that query
 /// terms targeting that field are expanded at query-time using the
 /// rules in the synonym map. This attribute can be changed on existing
 /// fields. Must be null or an empty collection for complex
 /// fields.</param>
 /// <param name="fields">A list of sub-fields if this is a field of
 /// type Edm.ComplexType or Collection(Edm.ComplexType). Must be null
 /// or empty for simple fields.</param>
 internal Field(string name, DataType type, bool?key = default(bool?), bool?retrievable = default(bool?), bool?searchable = default(bool?), bool?filterable = default(bool?), bool?sortable = default(bool?), bool?facetable = default(bool?), AnalyzerName?analyzer = default(AnalyzerName?), AnalyzerName?searchAnalyzer = default(AnalyzerName?), AnalyzerName?indexAnalyzer = default(AnalyzerName?), IList <string> synonymMaps = default(IList <string>), IList <Field> fields = default(IList <Field>))
 {
     Name           = name;
     Type           = type;
     Key            = key;
     Retrievable    = retrievable;
     Searchable     = searchable;
     Filterable     = filterable;
     Sortable       = sortable;
     Facetable      = facetable;
     Analyzer       = analyzer;
     SearchAnalyzer = searchAnalyzer;
     IndexAnalyzer  = indexAnalyzer;
     SynonymMaps    = synonymMaps;
     Fields         = fields;
     CustomInit();
 }
Beispiel #7
0
        private static void AssertIsLeaf(
            Field actualField,
            string expectedName,
            DataType expectedDataType,
            AnalyzerName?expectedAnalyzer = null)
        {
            Assert.Equal(expectedName, actualField.Name);
            Assert.Equal(expectedDataType, actualField.Type);

            Assert.Equal(expectedAnalyzer, actualField.Analyzer);
            Assert.Null(actualField.Fields);
            Assert.Null(actualField.IndexAnalyzer);
            Assert.False(actualField.IsFacetable);
            Assert.False(actualField.IsFilterable);
            Assert.False(actualField.IsKey);
            Assert.True(actualField.IsRetrievable);
            Assert.Equal(expectedAnalyzer != null, actualField.IsSearchable);
            Assert.False(actualField.IsSortable);
            Assert.Null(actualField.SearchAnalyzer);
            Assert.Null(actualField.SynonymMaps);

            actualField.Validate(); // Verify that Validate() doesn't throw.
        }