Gravatar for jeberhardy@rightpoint.com

Question by jeberhardy, Dec 4, 2018 7:02 PM

LINQ Query Support in Coveo for Sitecore 5

I see in the release notes for Coveo for Sitecore 5 that LINQ query support has been discontinued. What is the recommended approach for building custom renderings that rely on search queries for data results?

2 Replies
Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Dec 4, 2018 7:27 PM

A guide should be coming to our documentation in the following days that explains the alternatives in more details.

First, let me explain some of the reasons why Coveo decided to end the support of LINQ:

Static Content

Coveo is a relevance engine, not a data retrieval engine. There are no real advantages to using Coveo for retrieving, say, the 10 most recent results for a given template.

LINQ was implemented as an alternative to server-side content, but in the real world, in was used "as if it was a Sitecore index".

This is strengthened by the fact that Coveo does not want to replace the `sitecore_master_index` and should instead be used for end-users results retrieval, powered by end-users keywords.

Number of Results

The index expects that the relevant stuff will be within 1000 results, so it enforces a hard limit of 1000.

Say that you want those 1000 results to do some processing.

This same query executed with LINQ using Coveo would most probably end up being slower, because it passed through all of the Coveo pipelines just to have strictly no effect because it contained no contextual data.

Coupled with the "static content", we admit that some use cases, when no Machine Learning is required, using Sitecore's index is just easier and faster.

Number of Queries

Coveo for Sitecore 5 also removes support for Coveo Enterprise Search (On-Premises). In Coveo Cloud, there is a limit of queries per month as defined in your contract.

LINQ encourages to fetch more results than you should and even execute dependent queries, which most people were not aware of. They started hitting the limit fast, which frustrated people (with good reason).

Analytics and Machine Learning

Coveo for Sitecore's ContentSearch implementation could not provide Usage Analytics functionalities, which was not providing data for Machine Learning, which, in the end, resulted in a worse experience for our clients.

Coveo best strength is its ML capabilities on top of the relevance search by keyword.

Using LINQ means that you were only using the worst part of the whole Coveo for Sitecore offering.

----

We are instead encouraging you to build your interface using the Coveo for Sitecore Hive framework. If you have not tried it yet, I suggest that you do. It is way easier to build your dream search page using it than it was with legacy components.

If it does not fit your exact use case, tell us so that we prioritize features that are missing in our product.

----

Now, it is not _impossible_ to query the Coveo index using back-end code. But you must be ready to accept the consequences stated above.

The ContentSearch implementation used a simple client in the background to execute its queries. It was simply a wrapper over LINQ syntax to parse the code, generate a query, then bind back the result to a model.

This simple client is still present in our assemblies with the `Coveo.SearchServiceProvider.Rest.ClientSessionWrapperFactory`.

Instantiate the component, then create a client: `var client = factory.GetClientSessionWrapper(configuration, securityProviderName, currentUserName);`

You can now call `client.ExecuteQuery(new QueryParams() { ... })` which fronts most of the attributes supported by the Search API.

You could also create a simple client that calls `/coveo/rest` in your instance with the required parameters.

For more information about the Search API, see Developers - Search API

----

Let us know if this (quite lengthy) answer is answering your concerns :)

Gravatar for ssartell@rightpoint.com

Comment by ssartell, Dec 4, 2018 7:37 PM

That's quite the response. Thanks for the detail.

What about renderings driven by search in high-traffic areas? Before we could use Coveo with Content Search and then cache the rendering. Now the recommendation is to use Hive components and blow up their query counts?

The ClientSessionWrapperFactory sounds like an option, but clearly not the recommended path, and so what would the support of that be? Will it too be phased out?

Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Dec 4, 2018 7:14 PM

The recommended approach is to create Coveo JavaScript Search Framework components and wrap them in Sitecore renderings like Coveo for Sitecore Hive does with the out of the box components.

Ask a question