Gravatar for corrac@paragon-inc.com

Question by Cris Corra, Sep 11, 2014 10:58 AM

Is there a way to set the Sitecore ID of an item as the Coveo document key instead of item Name?

We're seeing a lot of issues in the item-bucket search if there are duplicate item Names (mainly in one folder, or item bucket folders).

Can we specify that Cove use the item ID for its key value instead of item Name?

-Cris Corra

*UPDATE (error when searching in Sitecore content editor)

5808 07:57:03 ERROR Application error. Exception: System.Reflection.TargetInvocationException Message: Exception has been thrown by the target of an invocation. Source: mscorlib at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Coveo.SearchProvider.LinqToCoveoIndex1.Execute[TResult](CoveoCompositeQuery p_Query) at Sitecore.ContentSearch.Linq.QueryableExtensions.GetResults[TSource](IQueryable1 source) at ItemBuckets.Services.Search.d__a.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Nested Exception

Exception: System.ArgumentException Message: An item with the same key has already been added. Source: mscorlib at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) at Coveo.SearchProvider.CoveoDocumentTypeMapper.ReadDocumentFields[TElement](QueryResult p_Document, IEnumerable1 pFieldNames, DocumentTypeMapInfo pDocumentTypeMapInfo, IEnumerable1 p_VirtualFieldProcessors, TElement p_Result) at Coveo.SearchProvider.CoveoDocumentTypeMapper.MapToType[TElement](QueryResult p_Document, SelectMethod p_SelectMethod, IEnumerable1 pVirtualFieldProcessors, SearchSecurityOptions pSecurityOptions, DocumentTypeMapInfo pTypeMapInfo) at Coveo.SearchProvider.DocumentTypeMapper.MapToType[TElement](QueryResult pDocument, SelectMethod pSelectMethod, IEnumerable1 p_VirtualFieldProcessors, IEnumerable1 pExecutionContexts, SearchSecurityOptions pSecurityOptions) at Coveo.SearchProvider.CoveoSearchResults1.<>c__DisplayClass5.<GetSearchHits>b__4(QueryResult result) at System.Collections.Generic.List1.ForEach(Action1 action) at Coveo.SearchProvider.CoveoSearchResults1.GetSearchHits() at Coveo.SearchProvider.LinqToCoveoIndex1.ApplyScalarMethod[TResult,TDocument](CoveoCompositeQuery p_CompositeQuery, CoveoSearchResults1 pProcessedResults, QueryResults p_Results)

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Sep 11, 2014 3:05 PM

This is because duplicate filtering is enabled by default. It filters your items because their body are the same. However, this cannot be configured for the moment.

A workaround could be to configure your filtered items to have a unique body. You can add the item id to the item body for example. This can be achieved with a BasicHtmlContentInBodyProcessor (See https://developers.coveo.com/display/SC201409/Indexing+Documents+with+Basic+HTML+Content )

Gravatar for corrac@paragon-inc.com

Comment by Cris Corra, Sep 12, 2014 8:00 AM

If I add FieldsToInclude to my processor setting, will that still include the other fields? Or just the ones I specify in that property?

The issue is trying to use the search in Sitecore. I updated my original post with the error since I only have so many characters to post a comment.

Ask a question