我正在尝试为以下型号创建索引。
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
答案 0 :(得分:2)
自从您实例化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
将很快被弃用,顺便说一句。
答案 1 :(得分:0)
您是否犯了拼写错误?看起来在Booking类中,您拥有“ BooknName”,索引称为“ bookname”。