Crawling root naming “gotcha!”

Short post for a small “gotcha” I experienced with indexing / crawling roots. I’m using indexing roots with Coveo for Sitecore (Hive) v4.1. I updated my roots and named them how I wanted them to be named, then rebuilt the index – only to find 0 items indexed, and the cloud panel reporting nothing happening.

The problem was, there wasn’t a crawling root with the default naming of ContentCrawler (or MediaItemCrawler for the media library). If you are indexing things in the content tree, you need at least one crawler with that exact name, or the rebuild will do nothing.

I don’t think you can have multiple crawlers with the same name, unless the crawlers are for different databases – meaning you can have two crawlers, both named ContentCrawler, one in your master index element and one in your web index element.

From my experience, other content crawlers after that (but within the same index element) can be named however you choose.

Render computed index field value in Coveo Hive search result template

There may come a time when you need to render the value of a custom field you created in the search results of your Coveo Hive search interface. Specifically, you would want to edit the search result template – hopefully you created a new one based on the file provided out of the box. How do you make the value appear though? I found this to be much more involved than I expected.

The isExternal setting

When it comes to rendering the value of the custom field, one setting is very important. In the fieldMap where you defined your custom field, you can choose whether you wish the field to be treated like a Coveo for Sitecore field (and to consequently appear in the content browser in a format such as fmyfield99999), or to be treated as an external (non-Sitecore) field, but still work with Coveo (and thus, appear without any characters added, like myfield). The setting you need to add or check: isExternal. Example:

 <fieldType fieldName="resultDate" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" isExternal="true" />

The underscore code required will depend on whether the value of that setting is true or false (false being the default). Whether you use {{ }} or <% %> syntax is up to you.

Coveo for Sitecore Fields

If the setting is false or not supplied, your field is a Coveo for Sitecore field, and could be rendered in one of the following ways:

1. Using the coveoFieldValue helper.

{{- coveoFieldValue("myfield") }}

2. Using the coveoFieldName helper in a div (WordPress didn’t like HTML in my blog post so I had to strip out the tag syntax):

div class="CoveoFieldValue" data-field="{{- coveoFieldName("contentType")}}" /div

If these don’t work, try adding @@ before the field name.

External Fields

If you provide the isExternal setting with a value of true, you can render the value of it using raw.

{{- raw.myfield }}

Using the coveoFieldName helper in a div also works.

Note that when using raw, the name of your field needs to be all lowercase, or the value will not be rendered. I was confused by this, because I entered my field name in the Coveo.SearchProvider.Custom.config as myField. Coveo support answered:

All the fields are actually translated to the index’s format, restricted to only lowercase letters, numbers and underscores:

https://onlinehelp.coveo.com/en/cloud/add_edit_fields.htm

During the indexing process, any field name that do not meet those requirements will be translated to that format (Coveo for Sitecore fields also get a unique hash added so that they are unique to each index).

Completion

You should be able to use the image() and date() helpers just fine now that you are using the correct syntax. Just note that if your field is external and you are using raw, your field name must be in lowercase. From what I can see, it doesn’t need to be all lowercase if you are using the other helpers. Hope this helps!

Error when serializing the property “RankingState”

I noticed this warning in the Experience Editor of a Coveo Hive search page, specifically on the search interface:

Warnings
  • RankingState
    • Error when serializing the property "RankingState". (Exception has been thrown by the target of an invocation.)

I immediately checked the Sitecore logs and found a long winded exception chain. The head exception was of course, “Exception has been thrown by the target of an invocation“. Many nested exceptions below that, at the very bottom of the chain, I found this error:

Exception: System.InvalidOperationException

Message: Cannot use DataAdapterProvider as xDB is disabled.

Source: Sitecore.Analytics.DataAccess

   at Sitecore.Analytics.DataAccess.DataAdapterProvider..ctor()

   at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider..ctor(Func`2 driverFactory)

Researching that error, I found that the problem was my settings in the Sitecore.Xdb.config file (under App_Config/Include). I had XDB disabled, but not XDB.Tracking disabled. I disabled XDB.Tracking and the warning went away. I assume if you have XDB disabled, you should also disable tracking because it relies on XDB. Just thought I’d quickly post this problem and solution as I continue working with Coveo Hive.

 

The Coveo Analytics are not enabled for this Search Interface

Last week I started working with Coveo Hive. There are a few strange things I ran into or wasn’t sure how to resolve. I’ll be writing a series of blog posts on these things as I continue to work on my very first Coveo Hive project.


I set up a Coveo Hive search page using the basic layout provided with Coveo for Sitecore. Opening the page in the Experience Editor, I immediately noticed an error in red:

The Coveo Analytics are not enabled for this Search Interface. Insert a Coveo Analytics component to record Coveo Usage Analytics data.

I thought the instruction here was a little bit vague. I also was shocked to not find much information in the documentation about this (specifically, how to enable usage analytics in Coveo Hive). In the previous Coveo framework, you would select the search interface in the Experience Editor, and check a box to enable Coveo Usage Analytics. In Hive, you add a component (as the literature dictates).

I wasn’t sure exactly where to insert it though, and how; but here’s what worked for me. The solution was to add a Coveo for Sitecore Analytics component to the UI Header, above the search box and search box settings. You may have to do some clicking and navigating the hierarchy of components to find the UI Header. Hope this helps!