Gravatar for jaroslav.kramer@cegeka.be

Question by jkramer, Nov 10, 2015 5:38 AM

Querying Coveo programmatically

Hello,

I'm trying to run a few queries against Coveo from C# code. However the SearchProviderFactory.CreateDefaultSearchProvider function throws a FailedToImpersonateUsersException for some reason. Queries run from a Coveo Search Page work fine. I've read that this might be a bug in one of the earlier CfS builds, I'm using the latest one though. Any ideas?

Additional data:

Current Coveo for Sitecore version: 3.0.1123.0

Current Sitecore version: 8.0.150427

Thanks,

JKramer

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Nov 10, 2015 11:19 AM

Hi Jaroslav,

SearchProviderFactory.CreateDefaultSearchProvider is a method from the Coveo .NET Search UI Framework assemblies. This UI framework is not included in Coveo for Sitecore and should not be used with it.

There are multiple ways to query the Coveo Enterprise Search index programmatically from Sitecore:

  • Sitecore LINQ module (uses the Coveo Enterprise Search "Search Service". Must query a particular Sitecore index and can query additional external sources)
  • REST queries through the Coveo for Sitecore REST endpoint proxy (http://YourSitecoreInstance/Coveo/rest) (Automatically does the query with the Sitecore authenticated user)
  • REST queries directly to the Coveo Search API REST endpoint proxy (http://YourCoveoSearchApiHost:8080/rest/search) (You must pass the user that runs the query. You must authenticate with the REST endpoint with an application secret)
  • Web service call to the Coveo Enterprise Search "Search Service" (https://YourCesHost:52810/7.0/CoveoSearchService) (You must use the cert-iis.p12 certificate from your CES index to authenticate. You must add the user that runs your program to the CES impersonators list if it is not the same that runs the CES service)

You should choose one of those methods first.

Gravatar for jaroslav.kramer@cegeka.be

Comment by jkramer, Nov 11, 2015 2:26 AM

Right, I had no idea that the classic interface wasn't in use by CfS. Thanks again for your help, Jean-François.

Gravatar for chris.williams@readwatchcreate.com

Comment by chris williams, Oct 31, 2018 10:28 AM

Do these still work with Coveo Cloud? If so which ones or are there alternative ways of doing this?

Gravatar for chris.williams@readwatchcreate.com

Comment by chris williams, Oct 31, 2018 10:28 AM

Do these still work with Coveo Cloud? If so which ones or are there alternative ways of doing this?

Ask a question