Search code examples
azure-cognitive-search

update azure search index results some fields to be null


I have an Azure Search Index with an Cosmos DB. In my DB I have four documents in one Collection. Each of the document have four fields: field1, field2, field3, field4. And all of them have a value, not NULL.

In Azure portal, currently my index has three fields (field1, field2, field3) as Searchable and Retrievable. The search is working properly and I can get four records with 3 fields and values.

Now I updated my index by adding a new field as field4 with Searchable and Retrievable. Then run my indexer to update the index. I noticed that only one record has the field4 with a value while the others have field4: null

I did the same testing several times and noticed it happens randomly to some of the records. Sometimes it gives me one record with field4 has a value. Sometimes it gives me two/three records with field4 has a value.

Does anyone know this issue and what's magic behind the scene?


Solution

  • Indexer is not going to update the index if the underlying Cosmos DB data hasn't changed, because indexing is incremental. To trigger a from-scratch reindexing, reset your indexer - you can do that using the reset indexer API or directly in Azure portal/indexer properties blade.

    The likely reason that you sometime see one or more changes "magically" picked up is that Azure Search incremental indexing logic compensates for time skew, so recently added Cosmos DB documents can be processed repeatedly.