Querying Coveo programmatically
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?
Current Coveo for Sitecore version: 3.0.1123.0
Current Sitecore version: 8.0.150427
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.p12certificate 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.