Gravatar for u.bannimatti@gmail.com

Question by Umesh Bannimatti, Feb 19, 2016 7:51 AM

Bucket items are not getting indexed in the Sitecore

We are using Coveo to implement search functionality. When we looked into CES Administration tool, we found that all items under sitecore are getting indexed except the bucket items. I searched for the option to index bucket items in the CES Administration tool, but I didn’t get any.

We are not using any Coveo Search Pages. We are using default coveo index i.e. Coveowebindex

Below is the code snippet we are using for retriving the results.

using (var context = ContentSearchManager.GetIndex("Coveo_web_index").CreateSearchContext())
{
    var query = context.GetQueryable<SearchResultItem>();
}

The "query" is not retriving any bucket items.

Please suggest me if there is any settings/options for indexing bucket items.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Feb 19, 2016 9:36 AM

Hi Umesh,

Bucket items and folders should be indexed by Coveo for Sitecore with the default configuration when everything is correctly setup.

The first things to check are:

  • The Coveo Diagnostic Page. Are all components green?
  • The Sitecore logs when you do a rebuild of your Coveomasterindex/Coveowebindex Sitecore indexes. Is there any error in the logs that may prevent those bucket items to be indexed? Any error may be important.

We already saw some cases of bucket items not indexed but they were all explained by either:

  • Using Sitecore 7.5+ with MongoDB service unavailable.
  • Having forgot to publish the template used by the bucket items in the web database.

Let me know what you find in the logs while rebuilding.

Thanks,

Jeff

Gravatar for u.bannimatti@gmail.com

Comment by Umesh Bannimatti, Feb 20, 2016 1:42 AM

Hi Jeff,

Thanks for your reply.

The bucket items are not getting indexed because we are overriding the method "GetItemUrl()" (Class: LinkProvider)

The bucket items are presentable items. Since these bucket items are located under bucket folder, The url doesn't seems to be user friendly. So we are overriding the method "GetItemUrl()" (Class: LinkProvider) We are using mvc routing to get the customurl for the bucket items.

If we don't override this method, bucket items are getting indexed. But we need to override this method to get user-friendly url.

Please suggest solution to resolve this.

The Code snippet is as below:

public override string GetItemUrl(Item item, UrlOptions urlOptions)
{
    var holdUrlOptions = urlOptions;
    try
    {
        urlOptions = LanguageHelper.CheckOverrideLanguageEmbedding(urlOptions);
        urlOptions.SiteResolving = Settings.Rendering.SiteResolving;
        var customUrl = String.Empty;
        if (CheckBucketTemplate(item, ILocation_Detail_PageConstants.TemplateId.ToString(), 
                    RouteConfig.RouteNames.Location.ToString(), RouteConfig.LocationRoute, 
                    urlOptions, out customUrl))
        {
            return customUrl;
        }
        return base.GetItemUrl(item, urlOptions);
    }
    catch (Exception ex)
    {
        urlOptions.SiteResolving = Settings.Rendering.SiteResolving;
        return base.GetItemUrl(item, holdUrlOptions);
    }
}

private bool CheckBucketTemplate(Item item, string templateId, 
                string routeName, string routeUrlTemplate, 
                UrlOptions urlOptions, out string customUrl)
{
    customUrl = "";
    if (item.TemplateID.ToString() == templateId)
    {
        var itemname = item.Name.EncodeParam();
        if (HttpContext.Current != null)
        {
            var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
            customUrl = urlHelper.RouteUrl(routeName, new {
                itemname
            });
        }
        else
        {
            customUrl = SetBucketItemUrlForAsyncTasks(itemname, routeUrlTemplate);
        }
        if (urlOptions.LanguageEmbedding == LanguageEmbedding.Always)
        {
            customUrl = "/" + Sitecore.Context.Language + customUrl;
        }
        if (!string.IsNullOrWhiteSpace(customUrl))
        {
            return true;
        }
    }
    return false;
}

private string SetBucketItemUrlForAsyncTasks(string itemname, string routeUrlTemplate
{
    return "/" + routeUrlTemplate.Replace("{itemname}", itemname);
}
1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Feb 22, 2016 4:10 PM

If I remember correctly, Coveo for Sitecore is way better dealing with absolute URLs than relative URLs. Try making the URLs returned by your custom link provider absolute instead of relative (Starting with a /).

Gravatar for u.bannimatti@gmail.com

Comment by Umesh Bannimatti, Feb 23, 2016 10:08 AM

Hi Jeff,

Thanks for your reply. After returning absolute Urls from our Custom Link Provider, It started indexing all the bucket Items. Thanks a lot.

Regards, Umesh

Ask a question