azure - 此 Azure 搜索索引错误意味着什么? "The property ' x' 在类型 'search.documentFields' 上不存在 ...”

标签 azure azure-cognitive-search azure-search-.net-sdk

我得到的异常是:类型“search.documentFields”上不存在属性“documentType”。确保仅使用由类型定义的属性名称。

我已经用谷歌搜索了这个,但仍然无法弄清楚发生了什么。

这是我们正在使用的模型:

[SerializePropertyNamesAsCamelCase]
public class WebSearchDocument : SearchDocument, IEventSearchDocument, IResourceSearchDocument
{
    [IsFacetable]
    public string DocumentType { get; set; }
    [IsSearchable]
    public string Title { get; set; }
    [IsSearchable]
    public string Description { get; set; }
    [IsFilterable]
    public DateTime? PublishedDate { get; set; }
    public DateTime? LastUpdatedDate { get; set; }
    public string ImageUrl { get; set; }
    public string LinkToResource { get; set; }
    public string EventCode { get; set; }
    [IsSearchable, IsFilterable]
    public string Location { get; set; }
    [IsFilterable]
    public DateTime? EventStartDate { get; set; }
    [IsFilterable]
    public DateTime? EventEndDate { get; set; }
}

最后,这是 Azure 上的索引字段 enter image description here

根据 @Bruce Johnson 的请求,这里有更多信息

服务名称:bacp-search
有问题的索引 bacp-web-dev
我们正在使用 Microsoft.Azure.Search 3.0.3 (NuGet)

搜索文档库:

[SerializePropertyNamesAsCamelCase]
public abstract class SearchDocument : ISearchDocument
{
    /// <summary>
    /// Gets or sets the ID for the document. For consistency, this should never be updated or retrieved manually.
    /// All IDs should be set through the <see cref="Id"/> property.
    /// </summary>
    [Key]
    [JsonProperty("Id")]
    public string AzureId { get; set; }

    /// <summary>
    /// Gets or sets any unique IDs or compound IDs that might contain characters unsafe for transmission via URL.
    /// For consistency, all IDs should be set through this property.
    /// </summary>
    [JsonIgnore]
    [IsRetrievable(false)]
    public string Id
    {
        get
        {
            return AzureId.FromBase64EncodedString();
        }
        set
        {
            AzureId = value.ToBase64EncodedString();
        }
    }
}

最佳答案

通常,此错误意味着索引定义中不存在索引有效负载中的属性。在此特定实例中,这是因为索引请求被发送到错误的索引,而目标索引实际上没有 documentType 字段。

关于azure - 此 Azure 搜索索引错误意味着什么? "The property ' x' 在类型 'search.documentFields' 上不存在 ...”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44203776/

相关文章:

linux - az login 在 Ubuntu 20.04 中是否停止工作?

Azure Lucene 模糊搜索

azure - 导入Azure HnswVectorSearchAlgorithmConfiguration出现错误: cannot import name 'HnswVectorSearchAlgorithmConfiguration'

在搜索中仅使用特殊字符的 Azure 搜索不会返回任何结果

c# - Azure 搜索合并索引操作返回异常

azure - Graph API - 自动获取电子邮件(委派权限)

php - 如何在 Laravel 中添加 azure 服务入口

azure - 如何完全删除 azure 网站

Azure 搜索服务的性能在生产环境和临时环境中有所不同

azure - Azure 搜索中的事件