簡體   English   中英

創建 azure 搜索索引時無法識別 IsSearchable

[英]IsSearchable not recognized when creating azure search index

我正在嘗試為以下模型創建索引。

public class Booking
    {
        [System.ComponentModel.DataAnnotations.Key]
        [IsSearchable,IsFilterable,IsSortable]
        public string BookId { get; set; }

        [IsSearchable, IsFilterable]
        public string BooknName { get; set; }
    }

創建索引的代碼

 FieldBuilder fieldBuilder = new FieldBuilder();
 var searchFields = fieldBuilder.Build(typeof(Booking));
 var definition = new SearchIndex(indexName, searchFields);
 indexClient.CreateOrUpdateIndex(definition);

在此處輸入圖片說明

但是,當我查看定義並創建索引並將所有這些設置為 false 時,這會以某種方式忽略IsSearchable/IsFilterable

這里還有我遺漏的其他財產嗎? 我正在使用Azure.Search.Documents - Version=11.1.1.0

由於您正在實例化FieldBuilder ,我假設您正在使用Azure.Search.Documents 在這種情況下,您需要使用我們添加的新屬性,例如SearchableFieldAttribute 前面的屬性有效地對應於屬性。 有關示例,請參見https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/samples/Sample04_FieldBuilderIgnore.md

Microsoft.Azure.Search很快就會被棄用,順便說一句。

你有沒有拼寫錯誤? 看起來在 Booking 類中,您有“BooknName”,而您的索引稱為“bookname”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM