What does this Azure Search indexing error mean? "The property 'x' does not exist on type 'search.documentFields'..."
Asked Answered
J

1

5

The Exception I am getting is: The property 'documentType' does not exist on type 'search.documentFields'. Make sure to only use property names that are defined by the type.

I have googled this and still cannot figure out what is going on.

Here is the model we are using:

[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; }
}

And finally, this is the index fields on Azure enter image description here

Per @Bruce Johnson request, here is more information

Service Name: bacp-search
Index in question bacp-web-dev
We are using Microsoft.Azure.Search 3.0.3 (NuGet)

SearchDocument Base:

[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();
        }
    }
}
Johnsonian answered 26/5, 2017 at 14:12 Comment(8)
I don't see any obvious problems here. I'll try to get a repro locally. In the meantime, can you share your service and index names, as well as the code you use to create the index client and the actual call to the Index/IndexAsync method?Always
It would also help to see the definition of the base class, SearchDocument. Also, which version of the Microsoft.Azure.Search package are you using?Always
I'm on the train but I will give you what you need once I'm homeJohnsonian
@BruceJohnston Sorry about the delay but I have updated the question with the information you asked for. A few notes, I did not write the base code to use Azure Search (a co-worker did but it was working). Also, this is work in progress for a client so I am not able to share all details but I will provide what I can.Johnsonian
From our logs it appears that the failed requests all target the wrong index -- bacp-register-dev instead of bacp-web-dev. bacp-register-dev does not have the documentType field. I've answered the question below based on this information for the benefit of others who may also run into this situation.Always
Also, I've taken the liberty of editing the question to only the parts that are relevant to this situation, now that we know what the issue is.Always
@BruceJohnston Thank you, I will test this out tomorrow and let you know. As for the edit of the question title, I knew what the error was but did not understand why or even how I was getting it.Johnsonian
@BruceJohnston Turns out that someone mistyped something in the AutoFac configuration so the wrong Index Name was being set. Thank you for helping figure this out.Johnsonian
A
7

In general, this error means that a property in the indexing payload is not present in the index definition. In this specific instance, it's because the indexing request is being sent to the wrong index, and the target index in fact does not have a documentType field.

Always answered 28/5, 2017 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.