Gravatar for chaturangar@gmail.com

Question by chaturangar, Dec 18, 2014 7:03 AM

Customizing Coveo for Sitecore search to add virtual language versions

Hi *,

I need to add a virtual language versions(which does not actually in sitecore) into coveo index when indexing an item. i.e. for example, if I create a new item in "en" language, when it is indexed to coveo, coveo should also have items in the index for other languages like "de-de", "en-us", etc (without creating those items in sitecore)

I tried to add a custom process into pipeline, but i'm stuck with how I can create virtual items.

Have anybody done this or any idea ?

Thank you in advance.

1 Reply
Gravatar for vseguin@coveo.com

Answer by Vincent Séguin, Dec 18, 2014 7:33 AM

Hi,

First of all, i would probably use a *CoveoItemPostProcessingPipeline which will make more sense for you're trying to achieve. Then, if you take a look at the 'CoveoPostItemProcessingPipelineArgs', you'll see that there's a CoveoItem and a list of OutputCoveoItems.

I would simply duplicate the CoveoItem, change its language for instance, and then add the duplicate in the list of OutputCoveoItems. These output items are the ones that will get indexed at the end.

You can learn more about this here : https://developers.coveo.com/display/public/SC201412/Using+the+Coveo+Pipelines

Does it make sense?

Gravatar for chaturangar@gmail.com

Comment by chaturangar, Dec 18, 2014 7:52 AM

Hi Vincent, Thank you for your quick reply. I looked into the link that you provided and I thought other way. But, after reading your solution, it seems like the best way. I will try it out. Best Regards

Gravatar for chaturangar@gmail.com

Comment by chaturangar, Dec 19, 2014 4:45 AM

Hi Vincent,

I tried your suggestion and it is working for some extent. But, I'm facing an issue with duplicating the CoveoItem. When try to clone return an error since it is not serializable class Then I tried to duplicate item using reflection, but it won't duplicate the metadata fields in coveoItem.

Do you have any advice/help regarding how to duplicate CoveoItem ?

Thanks in Advance! /Chaturanga

Gravatar for vseguin@coveo.com

Comment by Vincent Séguin, Dec 19, 2014 9:50 AM

Hi,

Why not just doing new CoveoIndexableItem() and just assign all the properties with the other one? Of course, for the metadatas, since it is a dictionary, you will need to clone the values.

Gravatar for klutz@absolute.com

Comment by krislutz, Jan 12, 2015 6:54 PM

I'm curious if you ever got this working. I am trying to do exactly the same thing. I create a new CoveoIndexableItem, set the values, and add it to the OutputCoveoItems array. I don't get any errors, however the new item never shows up in the index.

Gravatar for vseguin@coveo.com

Comment by Vincent Séguin, Jan 12, 2015 7:26 PM

Hi Kris,

You need to make sure to change the "UniqueId" of new the CoveoIndexableItem, for instance by appending a "1" or something at the end. If not, the index will consider the item as a duplicate of the other.

Gravatar for klutz@absolute.com

Comment by krislutz, Jan 13, 2015 12:15 PM

Thanks Vincent, that was exactly the problem.

Gravatar for klutz@absolute.com

Comment by krislutz, Jan 21, 2015 12:28 PM

This has been working well however I would like to prevent the deletion of the virtual language elements I create through this pipeline. So for example if I create a bunch of virtual en-gb items in the index based off the en version when en is published I then want to prevent them from getting removed when someone publishes en-gb (since they don't exist in sitecore). How would one go about intercepting the remove request via a pipeline?

Gravatar for vseguin@coveo.com

Comment by Vincent Séguin, Jan 21, 2015 1:33 PM

Removed != Deleted. If you see some "Removed" in the CES console, it doesn't mean they are deleted from the index.

Ask a question