1

I need to get the current active index name for Sitecore search for logging purposes. Because of the swap on rebuild functionality, I can't simply use the name field of the index, since on alternating rebuilds the name will change from the default to something like sitecore-master-index-1234. Searching Sitecore SE, it seems like there is no simple of way doing this. I went so far as to look at the disassembled code of Sitecore.ContentSearch.Azure, and it seems the field storing this name is marked internal so no one can access it outside of Sitecore.

Is there really no way to get this index name easily?

1 Answer 1

3

You could call the Azure Search Rest API directly to query the index-catalog

Example request:

GET xxx.search.windows.net/indexes/index-catalog/docs?search=*&$filter=sitecorename eq 'sitecore_web_index'

Result:

{
    "value": [
        {
            "@search.score": 1,
            "key": "SITECORE_WEB_INDEX-SEARCH",
            "sitecorename": "sitecore_web_index",
            "indextype": "SEARCH",
            "servicename": "sitecore-web-index-815"
        },
        {
            "@search.score": 1,
            "key": "SITECORE_WEB_INDEX-REBUILD",
            "sitecorename": "sitecore_web_index",
            "indextype": "REBUILD",
            "servicename": "sitecore-web-index"
        }
    ]
}

The result with indextype of SEARCH will give the current active index definition, you can then use the servicename for the index name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.