There is a custom code which triggers on rebuilding indexes. The method will extract all content from each page rendering's datasources and store in the content field.

When I debug, I see that the datasource content is correctly extracted. However, in the search method, the same content is not found.

//This function is triggered when rebuilding indexes is performed in CMS
public class SubcontentField : IComputedIndexField
    public object ComputeFieldValue(IIndexable indexable)
                var sitecoreIndexable = indexable as SitecoreIndexableItem;

                if (sitecoreIndexable == null)
                    return null;

                //it is assumed that the home item is the same in master & web databases
                Item homeItem = GetHomeItem(SiteName, MasterDatabaseName);
                List<string> contentToAdd = new List<string>();

                //add values (of only the page items that are under home) to the computed field.
                if (homeItem != null && (sitecoreIndexable.Item.ID == homeItem.ID || sitecoreIndexable.Item.Paths.IsDescendantOf(homeItem)))
                    // find renderings with datasources set
                    IEnumerable<Item> customDataSources = ExtractRenderingDataSourceItems(sitecoreIndexable.Item);
                    IEnumerable<Item> relatedItems = customDataSources.SelectMany(GetRelatedItems);

                    // extract text from data sources
                    contentToAdd = customDataSources.SelectMany(GetItemContent).ToList();

                    if (contentToAdd.Count == 0) return null;

                return string.Join("|", contentToAdd);

Search Method:

private void GetSearchResults(string keywords)
  using (var context = ContentSearchManager.GetIndex(index).CreateSearchContext())
                IQueryable<SearchResultItem> query = context.GetQueryable<SearchResultItem>()
                    .Where(x => x.Content.Contains(keywords) && x.Language == Sitecore.Context.Language.Name);
   if (query != null && query.Count() > 0)


I have checked for a particular keyword when rebuilding the web_index and when searched for the same, the query is always null.

We are using Azure Search.

  • Just noting that Azure Search has limitations: Documentation: "Substring searches that are limited to a single term, for instance, predicates, .StartsWith(), .EndsWith() and .Contains(), will match parts of terms, and will match terms that are located in any part of the field value. When multiple terms are passed, each term is searched separately, (this can provide more results than expected)." Also, are you trying this on Sitecore 8 or 9? Sitecore 9 appends a postfix to the field name depending on type.
    – TomT
    Commented Mar 9, 2018 at 3:00
  • hey, did you get a solution for this? Commented Jan 17, 2019 at 13:00

1 Answer 1


This first thing I'd do here is go to your Solr instance and query it directly to check if the content is there or not. e.g:


If it isn't then check your configuration for your computed field is correct. e.g:

<defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
                <fields hint="raw:AddComputedIndexField">
                        <field fieldName="subcontent" storageType="YES" returnType="text">YourNameSpace.SubContentField</field>
  • I'm using azure search and no access to portal. Any other way. What abt the code. Is there something wrong with it
    – sukesh
    Commented Feb 6, 2018 at 11:24
  • It looks like you can still query it directly: docs.microsoft.com/en-us/azure/search/search-explorer Commented Feb 6, 2018 at 11:26
  • Do not have access to the portal.
    – sukesh
    Commented Feb 6, 2018 at 11:37
  • Ok if this really isn't possible, looking at your Search query it looks ok. Try also adding Or predicates for Lowercase and Titlecase versions of the query to check it's not an casing issue. Commented Feb 6, 2018 at 11:52
  • I checked the content field in a for loop too. It doesnt have the keyword at all.
    – sukesh
    Commented Feb 6, 2018 at 12:02

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.