如何解决创建天蓝色搜索索引时无法识别IsSearchable
我正在尝试为以下型号创建索引。
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”。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。