Allan Xu
Allan Xu

Reputation: 9368

Why does Azure AI Search REST API return different indexer status than the Azure Portal?

I am using Azure AI Search.

In the Azure portal, I have an indexer with a 'Failed' status:

enter image description here

In my application, I retrieve the indexer's status using the following REST API call:

GET https://[service name].search.windows.net/indexers/[indexer name]/status?api-version=2024-07-01

as documented here:

https://learn.microsoft.com/en-us/rest/api/searchservice/indexers/get-status?view=rest-searchservice-2024-07-01&tabs=HTTP

I get this response:

enter image description here

Discrepancy: The REST API response differs from the Azure Portal's display. Specifically, as shown in my screenshot.

Question: How can I retrieve the indexer's status via the REST API to match the status displayed in the Azure Portal?

Could this be a bug in the REST API?

Upvotes: 0

Views: 93

Answers (1)

JayashankarGS
JayashankarGS

Reputation: 8140

What you are checking is lastResult which is the most recent run or in progress run will be returned. In your case i can see it is success 2 mins ago and returned correct results via api also.

check this documentation for response definitions.

For checking all the run status, you extract executionHistory from response.

Here is sample code for it.

headers = {"Context-Type": "text/json", "api-key": "PiVvxxxxxyyyyyy"}

response = requests.get(
    url="https://<endpoint>/indexers('azureblob-indexer')/search.status?api-version=2024-07-01", headers=headers
)

for i in response.json()['executionHistory']:
    print(i['status'])

Output:

enter image description here

and in portal

enter image description here

Upvotes: 0

Related Questions