-1

I have created a separate publishing target (Production). I have created a separate index for this database (sitecore_prod_index).

I rebuild my index, and it returns results.

I rebuild again, no results. I can browse the index in azure and see that my results are there, but my code calling search does not return results.

I rebuild a third time and I get results.

Its like one of the rebuild indexes doesn't work, but the other does.

I'm performing a search like so:

using (var context = SiteSearchIndex.CreateSearchContext())
{
    var results = context.GetQueryable<MySearchResultModel>()
      .Where(x => x.Paths.Contains(MyItemRoot.ID) && x.TemplateId == DetailPageConstants.TemplateId).GetResults();

    if (results.TotalSearchResults > 0)
    {
         return results.Hits.Select(q => q.Document).ToList();
    }

    return null;
}

SiteSearchContext is an ISearchIndex and it know which index to call (sitecore_web_index or sitecore_prod_index) based on a appsettings in the web config:

var searchIndexName = $"sitecore_{Context?.SitecoreService?.Database?.Name}_index";
var configuredIndexName = ConfigurationManager.AppSettings["SearchIndexName"];
if (!string.IsNullOrEmpty(configuredIndexName))
{
    searchIndexName = configuredIndexName;
}

SiteSearchIndex = ContentSearchManager.GetIndex(searchIndexName);
1

I can't say for sure if you have had the same issue as myself and Gatogordo but in 8.2 u7 and 9.02 there is a bug that prevents the active index name being updated correctly in the core db on CD servers. I've not got round to blogging about it but will do when I get a minute.

If this bug also exists with 9.1 you should be able to get a hotfix from support also.

You can read more info on this here: Getting the primary Azure Search Index name after index re-build

The hotfix for 8.2.7 moved storage of the index name in use into an Azure index instead of the core db and this works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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