azure 认知搜索中的嵌入字段

时间:2021-06-25 21:14:53

标签: azure-cognitive-search

我正在尝试为 Azure 认知搜索中的索引创建评分配置文件。但是,我的数据源包含嵌入的字段 - 它包含一个名为 metadataList 的自定义对象类型 MetaData 的 IList。创建评分配置文件时如何引用MetaData的字段?

这是我用来建模数据的类的一部分:

[SerializePropertyNamesAsCamelCase]
public class MetaDataFileIndex
{
        [IsRetrievable(true)]
        public IList<MetaDataIndex> MetadataList { get; set; }

//Some other properties bellow
}

[SerializePropertyNamesAsCamelCase]
public class MetaDataIndex
{
        [IsRetrievable(true), IsSearchable]
        [Analyzer(AnalyzerName.AsString.ZhHantLucene)]
        public string PrimarySortText { get; set; }

//Some other properties bellow
}

这是我用于创建索引的一些代码:

fields = FieldBuilder.BuildForType<MetaDataFileIndex>();

var index = new Index()
{
    Name = name,
    Fields = fields,
    ScoringProfiles = new List<ScoringProfile>()
    {
        new ScoringProfile
        {
            Name = "fieldBooster",
            TextWeights = new TextWeights
            {
                Weights = new Dictionary<string, double>
                {
                    { "metadataList/primarySortText", [some number here] },

\\Rest of the code

这给了我一个错误。当我使用服务客户端创建或更新索引时,收到“请求无效错误”。

   at Microsoft.Azure.Search.IndexesOperations.<CreateOrUpdateWithHttpMessagesAsync>d__9.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at Microsoft.Azure.Search.IndexesOperationsExtensions.<CreateOrUpdateAsync>d__1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at 

我相信这是因为我在评分配置文件中提到“主要排序文本字段”的方式,因为当我运行相同的代码但没有在 MetaDataFileIndex 中使用其他对象类型的列表时,它给了我没有错误。我如何引用这样的嵌入字段?

编辑:我的 Azure 认知搜索版本是 11.2.0,它被称为 Azure.Search.Documents

0 个答案:

没有答案