12

After upgrade to Coveo 4.0 I am getting an error related to the version field. Here is the query I am running in Linq Scratch Pad:

using (var context = ContentSearchManager.GetIndex("Coveo_web_index").CreateSearchContext())
{
    return context.GetQueryable<SearchResultItem>().Take(10).ToList();
}

As you can see the query itself is no magic, I did not change it.

The Searchprovider.config by default has:

<fields hint="raw:AddComputedIndexField">
    <field fieldName="calculateddimension">Sitecore.ContentSearch.ComputedFields.CalculatedDimension,Sitecore.ContentSearch</field>
    <field fieldName="istemplate">Sitecore.ContentSearch.ComputedFields.IsTemplate,Sitecore.ContentSearch</field>
    <field fieldName="haschildren">Sitecore.ContentSearch.ComputedFields.HasChildren,Sitecore.ContentSearch</field>
    <field fieldName="lock">Sitecore.ContentSearch.ComputedFields.IsLocked,Sitecore.ContentSearch</field>
    <field fieldName="parsedcreatedby">Sitecore.ContentSearch.ComputedFields.ParsedCreatedBy,Sitecore.ContentSearch</field>
    <field fieldName="parsedupdatedby">Sitecore.ContentSearch.ComputedFields.ParsedUpdatedBy,Sitecore.ContentSearch</field>
    <field fieldName="parsedlanguage">Sitecore.ContentSearch.ComputedFields.ParsedLanguage,Sitecore.ContentSearch</field>
    <field fieldName="site">Sitecore.ContentSearch.ComputedFields.Site,Sitecore.ContentSearch</field>
    <field fieldName="sizerange">Sitecore.ContentSearch.ComputedFields.FileSizeGrouping,Sitecore.ContentSearch</field>
    <field fieldName="version">Sitecore.ContentSearch.ComputedFields.StoreVersionTermVector,Sitecore.ContentSearch</field>
    <field fieldName="urllink">Sitecore.ContentSearch.ComputedFields.UrlLink,Sitecore.ContentSearch</field>
    <field fieldName="isbucket_text">Sitecore.ContentSearch.ComputedFields.IsBucket,Sitecore.ContentSearch</field>
    <field fieldName="alltemplates">Sitecore.ContentSearch.ComputedFields.AllTemplates, Sitecore.ContentSearch</field>
</fields>

And in the index I can see the version field. @fversion24653 String 1

I get the error:

Property accessor 'Version' on object 'Sitecore.ContentSearch.SearchTypes.SearchResultItem' threw the following exception:'The given key was not present in the dictionary.'

I have index all fields as true.

<coveoQueryFieldPipeline patch:source="Coveo.SearchProvider.config">
    <processor type="Coveo.SearchProvider.Processors.Queries.AddAllFieldsProcessor, Coveo.SearchProviderBase"/>
</coveoQueryFieldPipeline>

The base Coveo.SearchProvider.config indexes version, id and unique id fields.

<fieldType fieldName="_id" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" type="Sitecore.Data.ID, Sitecore.Kernel" returnType="System.String" />
<fieldType fieldName="_uniqueid" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" type="Sitecore.Data.ItemUri, Sitecore.Kernel" returnType="System.String" />
<fieldType fieldName="name" isFacet="true" isSortable="true" includeForFreeTextSearch="true" isMultiValue="false" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

<fields hint="raw:AddComputedIndexField">
    <field fieldName="calculateddimension">Sitecore.ContentSearch.ComputedFields.CalculatedDimension,Sitecore.ContentSearch</field>
    <field fieldName="istemplate">Sitecore.ContentSearch.ComputedFields.IsTemplate,Sitecore.ContentSearch</field>
    <field fieldName="haschildren">Sitecore.ContentSearch.ComputedFields.HasChildren,Sitecore.ContentSearch</field>
    <field fieldName="lock">Sitecore.ContentSearch.ComputedFields.IsLocked,Sitecore.ContentSearch</field>
    <field fieldName="parsedcreatedby">Sitecore.ContentSearch.ComputedFields.ParsedCreatedBy,Sitecore.ContentSearch</field>
    <field fieldName="parsedupdatedby">Sitecore.ContentSearch.ComputedFields.ParsedUpdatedBy,Sitecore.ContentSearch</field>
    <field fieldName="parsedlanguage">Sitecore.ContentSearch.ComputedFields.ParsedLanguage,Sitecore.ContentSearch</field>
    <field fieldName="site">Sitecore.ContentSearch.ComputedFields.Site,Sitecore.ContentSearch</field>
    <field fieldName="sizerange">Sitecore.ContentSearch.ComputedFields.FileSizeGrouping,Sitecore.ContentSearch</field>
    <field fieldName="version">Sitecore.ContentSearch.ComputedFields.StoreVersionTermVector,Sitecore.ContentSearch</field>
    <field fieldName="urllink">Sitecore.ContentSearch.ComputedFields.UrlLink,Sitecore.ContentSearch</field>
    <field fieldName="isbucket_text">Sitecore.ContentSearch.ComputedFields.IsBucket,Sitecore.ContentSearch</field>
    <field fieldName="alltemplates">Sitecore.ContentSearch.ComputedFields.AllTemplates, Sitecore.ContentSearch</field>
</fields>

EDIT #1:

Also seeing the following error:

46984 13:14:44 WARN  The current item could not be processed by the field processor Sitecore.ContentSearch.VirtualFields.LatestVersionFieldProcessor.
Exception: System.Collections.Generic.KeyNotFoundException
Message: The given key was not present in the dictionary.
Source: mscorlib
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Sitecore.ContentSearch.VirtualFields.LatestVersionFieldProcessor.TranslateFieldResult(IDictionary`2 fields, FieldNameTranslator fieldNameTranslator)
at Coveo.SearchProvider.CoveoDocumentTypeMapper.ReadDocumentFields[TElement](QueryResult p_Document, IEnumerable`1 p_FieldNames, DocumentTypeMapInfo p_DocumentTypeMapInfo, IEnumerable`1 p_VirtualFieldProcessors, TElement p_Resul

2 Answers 2

6

In Sitecore 8.1, the Version property for Sitecore.ContentSearch.SearchTypes.SearchResultItem extracts the version from the URI set by the _uniqueid field.

It looks like that field is not indexed for your documents.

You could create a custom SearchResultItem that uses the @fversion24653 field and see how it goes.

4
  • @flguilemette In the Coveo.SearchProvider.config I see that the _uniqueid field is indexed. <fieldType fieldName="_uniqueid" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" type="Sitecore.Data.ItemUri, Sitecore.Kernel" returnType="System.String" />
    – ASura
    Commented Oct 12, 2016 at 16:46
  • Did you check if the field is correctly indexed on a document? Have you tried creating a custom SearchResultItem? Commented Oct 12, 2016 at 17:10
  • trying just a plain old custom search result item without inheriting the SearchResultItem
    – ASura
    Commented Oct 12, 2016 at 17:36
  • Do you get any results back if you try the search with something like return context.GetQueryable<SearchResultItem>().Where(resultItem=>resultItem["version"]!="").Take(10).ToList(); Edit: Just saw your edit as well, most likely there will be no results Commented Oct 12, 2016 at 18:32
2

So turns out that this issue is a bit more complicated. After troubleshooting for days we figured out that this was a redirection issue. Nothing in the application but its how Coveo 4 handles redirection.

CM Site: https://cm.mysite.com CES Site: http://myCESServer

From Coveo 4 on, the server side Linq to Search requests go through the Coveo Search API via a secured POST call.

The client side js api calls the Coveo Search API using a get call.

Get can move between https and http without an issue but POST on the other hand cannot.

When the query was run on the CM server using Linq to Search (https://cm.mysite.com/somepagewhichrunsquery), it generates a post request and (HERE IS WHERE IT GOES WRONG) posts it to the non https version of the url http://cm.mysite.com/coveo/rest this forces the NLB to push it to https and this causes the search to end up as @uri instead.

This issue causes many others. My other ticket related to coveo indexing 1300+ items also suffers from the same issue.

How do we fix this? Well. For us, we needed a hotfix for Coveo July 2016 release since we were already in production.

But this fix is going to be part of the October 2016 release - which is due to be release in a couple of days.

You can find the downloads at https://developers.coveo.com/display/public/SitecoreV4/Downloads

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.