SearchIndex.Fields プロパティ

定義

インデックス内のフィールドを取得または設定します。 モデル クラスまたは SimpleFieldSearchableFieldComplexField、 に基づいてフィールドを定義し、フィールドを手動で定義するには、 を使用FieldBuilderします。 インデックス フィールドには、サーバーで SearchField インデックスが作成されるまで検証されない制約が多数あります。

public System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.SearchField> Fields { get; set; }
member this.Fields : System.Collections.Generic.IList<Azure.Search.Documents.Indexes.Models.SearchField> with get, set
Public Property Fields As IList(Of SearchField)

プロパティ値

を使用して、モデル クラスからフィールドを FieldBuilder作成できます。

SearchIndex index = new SearchIndex("hotels")
{
    Fields = new FieldBuilder().Build(typeof(Hotel)),
    Suggesters =
    {
        // Suggest query terms from the HotelName field.
        new SearchSuggester("sg", "HotelName")
    }
};

このため、 Fields は設定可能です。 モデルが不明または変更できないシナリオでは、ヘルパー クラスを使用してフィールドを手動で作成することもできます。

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")
    }
};

適用対象