Class SearchIndex
Represents a search index definition, which describes the fields and search behavior of an index.
Inheritance
Namespace: System.Dynamic.ExpandoObject
Assembly: Azure.Search.Documents.dll
Syntax
public class SearchIndex
Constructors
SearchIndex(String)
Initializes a new instance of the SearchIndex class.
Declaration
public SearchIndex (string name);
Parameters
System.String
name
The name of the index. |
Exceptions
System.ArgumentException
|
System.ArgumentNullException
|
SearchIndex(String, IEnumerable<SearchField>)
Initializes a new instance of the SearchIndex class.
Declaration
public SearchIndex (string name, System.Collections.Generic.IEnumerable<Azure.Search.Documents.Indexes.Models.SearchField> fields);
Parameters
System.String
name
The name of the index. |
System.Collections.Generic.IEnumerable<SearchField>
fields
Fields to add to the index. |
Exceptions
System.ArgumentException
|
System.ArgumentNullException
|
Properties
Analyzers
Gets the analyzers for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.LexicalAnalyzer> Analyzers { get; }
Property Value
System.Collections.Generic.IList<LexicalAnalyzer>
|
CharFilters
Gets the character filters for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.CharFilter> CharFilters { get; }
Property Value
System.Collections.Generic.IList<CharFilter>
|
CorsOptions
Options to control Cross-Origin Resource Sharing (CORS) for the index.
Declaration
public Azure.Search.Documents.Indexes.Models.CorsOptions CorsOptions { get; set; }
Property Value
CorsOptions
|
DefaultScoringProfile
The name of the scoring profile to use if none is specified in the query. If this property is not set and no scoring profile is specified in the query, then default scoring (tf-idf) will be used.
Declaration
public string DefaultScoringProfile { get; set; }
Property Value
System.String
|
EncryptionKey
A description of an encryption key that you create in Azure Key Vault. This key is used to provide an additional level of encryption-at-rest for your data when you want full assurance that no one, not even Microsoft, can decrypt your data in Azure Cognitive Search. Once you have encrypted your data, it will always remain encrypted. Azure Cognitive Search will ignore attempts to set this property to null. You can change this property as needed if you want to rotate your encryption key; Your data will be unaffected. Encryption with customer-managed keys is not available for free search services, and is only available for paid services created on or after January 1, 2019.
Declaration
public Azure.Search.Documents.Indexes.Models.SearchResourceEncryptionKey EncryptionKey { get; set; }
Property Value
SearchResourceEncryptionKey
|
ETag
The Azure.ETag of the SearchIndex.
Declaration
public Nullable<Azure.ETag> ETag { get; set; }
Property Value
System.Nullable<Azure.ETag>
|
Fields
Gets or sets the fields in the index. Use FieldBuilder to define fields based on a model class, or SimpleField, SearchableField, and ComplexField to manually define fields. Index fields have many constraints that are not validated with SearchField until the index is created on the server.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.SearchField> Fields { get; set; }
Property Value
System.Collections.Generic.IList<SearchField>
|
Examples
You can create fields from a model class using FieldBuilder:
SearchIndex index = new SearchIndex("hotels")
{
Fields = new FieldBuilder().Build(typeof(Hotel)),
Suggesters =
{
// Suggest query terms from the hotelName field.
new SearchSuggester("sg", "hotelName")
}
};
For this reason, Fields is settable. In scenarios when the model is not known or cannot be modified, you can also create fields manually using helper classes:
SearchIndex index = new SearchIndex("hotels")
{
Fields =
{
new SimpleField("hotelId", SearchFieldDataType.String) { IsKey = true, IsFilterable = true, IsSortable = true },
new SearchableField("hotelName") { IsFilterable = true, IsSortable = true },
new SearchableField("description") { AnalyzerName = LexicalAnalyzerName.EnLucene },
new SearchableField("tags", collection: true) { IsFilterable = true, IsFacetable = true },
new ComplexField("address")
{
Fields =
{
new SearchableField("streetAddress"),
new SearchableField("city") { IsFilterable = true, IsSortable = true, IsFacetable = true },
new SearchableField("stateProvince") { IsFilterable = true, IsSortable = true, IsFacetable = true },
new SearchableField("country") { IsFilterable = true, IsSortable = true, IsFacetable = true },
new SearchableField("postalCode") { IsFilterable = true, IsSortable = true, IsFacetable = true }
}
}
},
Suggesters =
{
// Suggest query terms from the hotelName field.
new SearchSuggester("sg", "hotelName")
}
};
Name
Gets the name of the index.
Declaration
public string Name { get; }
Property Value
System.String
|
Normalizers
Gets the normalizers for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.LexicalNormalizer> Normalizers { get; }
Property Value
System.Collections.Generic.IList<LexicalNormalizer>
|
ScoringProfiles
Gets the scoring profiles for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.ScoringProfile> ScoringProfiles { get; }
Property Value
System.Collections.Generic.IList<ScoringProfile>
|
SemanticSettings
Defines parameters for a search index that influence semantic capabilities.
Declaration
public Azure.Search.Documents.Indexes.Models.SemanticSettings SemanticSettings { get; set; }
Property Value
SemanticSettings
|
Similarity
The type of similarity algorithm to be used when scoring and ranking the documents matching a search query. The similarity algorithm can only be defined at index creation time and cannot be modified on existing indexes. If null, the ClassicSimilarity algorithm is used.
Declaration
public Azure.Search.Documents.Indexes.Models.SimilarityAlgorithm Similarity { get; set; }
Property Value
SimilarityAlgorithm
|
Suggesters
Gets the suggesters for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.SearchSuggester> Suggesters { get; }
Property Value
System.Collections.Generic.IList<SearchSuggester>
|
TokenFilters
Gets the token filters for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.TokenFilter> TokenFilters { get; }
Property Value
System.Collections.Generic.IList<TokenFilter>
|
Tokenizers
Gets the tokenizers for the index.
Declaration
public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.LexicalTokenizer> Tokenizers { get; }
Property Value
System.Collections.Generic.IList<LexicalTokenizer>
|