问题
1) Suppose I use the Azure Search API to upload a new document:
POST /indexes/[index name]/docs/index?api-version=[api-version]
2) I get a response with an HTTP code 201 (document was successfully created)
3) I use the API again to search the newly uploaded document
Can I be 100% sure that I will get the document in the results? Or could there be a delay in the indexing process?
回答1:
No, it's not guaranteed the document will be returned in the query. The usual delay is on the order of seconds, but depending on the overall system load it can take longer. You'll need to run tests on your service to find the typical delay in your application.
Azure Search offers eventual consistency which means the index will be consistent at some time in the future but exactly when is not guaranteed.
Even polling for the document until it shows up in a query result is not sufficient to always guarantee consistency for indexes with multiple replicas, because requests can be interleaved with documents merging into replicas of the index. For example
- Replicas A and B are consistent
- Client uploads new document
- Replica A receives the upload request
- Replica A processes the upload request and is ready to return the new document in query results
- Client queries for the new document, which happens to be served by Replica A, and gets the new document in the result
- Client queries for the new document again, which happens to be served by Replica B this time, and does not get the new document in the result
- New document is processed by Replica B
- Both replicas are now consistent again
来源:https://stackoverflow.com/questions/56012381/right-after-uploading-a-document-on-azure-search-can-i-query-it