通过 sdk 在 Azure 搜索中设置 Edm.ComplexType
Set Edm.ComplexType in Azure Search by sdk
我在 Azure 搜索中遇到问题,我从 blob 存储中的 csv 文件获取数据。为简化起见,假设我的对象为:
public class Instrument
{
public Identifier Identifier { get; set; }
[SearchableField(IsSortable = true, IsKey = true)]
public string Id { get; set; }
[SearchableField(IsSortable = true)]
public string RefIs { get; set; }
}
public class Identifier
{
[SearchableField(IsSortable = true)]
public string Code { get; set; }
}
当我收到我的数据时,它在 csv 中是扁平的,例如:_id、_ref、_code
当我通过 SDK 创建索引时,我为简单字段设置了映射:
indexer.FieldMappings.Add(new FieldMapping("_ref")
{
TargetFieldName = "RefIs"
});
但我无法弄清楚在我的索引器中将其声明为复杂类型的方式?给定的代码不适用于它:
indexer.FieldMappings.Add(new FieldMapping("_code")
{
TargetFieldName = "Code"
});
indexer.FieldMappings.Add(new FieldMapping("_code")
{
TargetFieldName = "Identifier.Code"
});
错误是相同的 TargetField 不存在于索引中。
有人可以帮忙吗?
最好的克服方法是按照自己的方式解析 .csv 文件,然后 post 使用暴露的 API 将文档发送到 ACS。这是最有效的方法(不要依赖内置序列化器)
我在 Azure 搜索中遇到问题,我从 blob 存储中的 csv 文件获取数据。为简化起见,假设我的对象为:
public class Instrument
{
public Identifier Identifier { get; set; }
[SearchableField(IsSortable = true, IsKey = true)]
public string Id { get; set; }
[SearchableField(IsSortable = true)]
public string RefIs { get; set; }
}
public class Identifier
{
[SearchableField(IsSortable = true)]
public string Code { get; set; }
}
当我收到我的数据时,它在 csv 中是扁平的,例如:_id、_ref、_code 当我通过 SDK 创建索引时,我为简单字段设置了映射:
indexer.FieldMappings.Add(new FieldMapping("_ref")
{
TargetFieldName = "RefIs"
});
但我无法弄清楚在我的索引器中将其声明为复杂类型的方式?给定的代码不适用于它:
indexer.FieldMappings.Add(new FieldMapping("_code")
{
TargetFieldName = "Code"
});
indexer.FieldMappings.Add(new FieldMapping("_code")
{
TargetFieldName = "Identifier.Code"
});
错误是相同的 TargetField 不存在于索引中。
有人可以帮忙吗?
最好的克服方法是按照自己的方式解析 .csv 文件,然后 post 使用暴露的 API 将文档发送到 ACS。这是最有效的方法(不要依赖内置序列化器)