Gravatar for shirazi@rdacorp.com

Question by aga, Apr 4, 2016 12:42 PM

No Results using Coveo Linq Query on external source

Hi

I'm using coveo for sitecore (3.0 1116) and my CES is indexing sitecore data as well a DB as an external source. I am able to issue queries from the Sitecore Search page using REST and get results for the DB and Sitecore data.

Now, I'm trying to issue a query using linq to get results from the external source (DB data), but I'm not getting results back. I even checked the CES Console and 0 results were being returned. Now, when I take the raw query from the console and run that in the index browser and I get results! This makes me think it's a security issue. The external source has the "everyone" group added from my sitecore security provider.

Any other hints on what might the issue be?

var searchIndex = ContentSearchManager.GetIndex(indexName);

using (var context = searchIndex.CreateSearchContext(SearchSecurityOptions.DisableSecurityCheck))
{

    ICoveoSearchContext coveoContext = context as ICoveoSearchContext;

    coveoContext.SearchContextOptions = new CoveoSearchContextOptions { ExternalSources = new List<string>() { "Products" } };

    CustomSearchResultItem p = context.GetQueryable<CustomSearchResultItem>().Where(
           i => i.CustomField.Equals("Tools")).FirstOrDefault();
}

Here is the output from CES Console:

4/4/2016 1:43:17 PM | Query ((@customfield=="Tools") OR (@syssource="Products"))((@customfield=="Tools")) performed by coveo\admin [Sitecore Security Provider for local]. 0 results in 0.187 seconds.
Gravatar for slangevin@coveo.com

Comment by Simon, Apr 4, 2016 1:25 PM

Using the CES Console, you should see the LINQ query translated in a Coveo query. Use this query in the index browser to see if it is a security issue or a field issue.

Gravatar for shirazi@rdacorp.com

Comment by aga, Apr 4, 2016 1:29 PM

Hi Simon, i did use the CES console to get the query and ran that against the index browser and that in fact worked! As i mentioned in my post, the query works from the browser but not from linq

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 4, 2016 1:38 PM

Look at the CES query logs. You will see the basic, advanced query and constant parts of each query you made with LINQ. While querying in the index browser, join all those parts with a space between each to reproduce the complete LINQ query.

You should have a @syssource=="Products" expression in one of the query parts.

If it still returns results, that's maybe a security issue.

Gravatar for shirazi@rdacorp.com

Comment by aga, Apr 4, 2016 1:47 PM

Ive updated the post with the CES output. When i run ((@customfield=="Tools") OR (@syssource="Products"))((@customfield=="Tools")) in the index browser i get results

Gravatar for slangevin@coveo.com

Comment by Simon, Apr 4, 2016 3:22 PM

Then it could be a permission issue. In the index browser, you can see the permission of the item under the Details >> Permission section.

In the CES console, you will see the user making the query

0 Reply
Ask a question