Gravatar for mskutta@onenorth.com

Question by Mike Skutta, Dec 1, 2016 2:08 PM

Sitecore v4 Pro Cloud Edition v2 appears to OR .Where and .CoveoWhere

Hello,

According to this link: https://developers.coveo.com/display/public/SitecoreV4/Coveo+LINQ+Extensions, "The CoveoWhere is used to add free text terms or Coveo query syntax terms to a query. The result is a query using the AND operator between the original query and the terms specified in the parameter."

I am finding when I run queryable.Where(...).CoveoWhere("Free Text Terms").Tolist(); it appears to be doing an OR operator between the .Where and .CoveoWhere.

Note: running queryable.Where(…) without the .CoveoWhere(…) filters the results correctly. Adding .CoveoWhere appears to negate the .Where(…) query. Not sure if this makes a difference, but the fields I am filtering on in the .Where(…) have been flagged as facets.

This issue is occurring on the Coveo Pro Cloud Edition v2. We have not seen this issue running the On-premises edition.

Current Coveo for Sitecore version: 4.0.450.0 Current Sitecore version: 8.1.160519

Thanks, Mike

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 2, 2016 8:17 AM

Using the GetCoveoQueryResults extension, could you provide us the textual query that is being executed on the index using:

results = query.GetCoveoQueryResults();
string query = String.Format("({0} {1}) {2}", 
                             results.Debug.BasicExpression,
                             results.Debug.AdvancedExpression,
                             results.Debug.ConstantExpression);

This will help us shed some light on the issue here :)

Also, I am not certain to understand your issue.

Say I have

query.Where(res => res.Title != "title")
     .CoveoWhere("something")

I will get NOT @ftitle24765==title something, this is effectively an "AND" between them since I want documents that don't have that specific title, plus have the "something" keyword somewhere.

Whereas

query.Where(res => res.Title != "title");

will return all documents that don't have my specific title. And

query.CoveoWhere("something")

will return all documents matching "something" in any field that is free-text search.

Gravatar for mskutta@onenorth.com

Comment by Mike Skutta, Dec 2, 2016 9:03 AM

Running:

query.Where(x => x.SiteSection.Contains("efd2c88efb1d4ef1ab1e4e17a973a708")).CoveoWhere("phillips");

Query:

(phillips ) @syssource="Coveo_web_index - 1N-L-MSKUTTA10-Sidley81u3"

Running:

query.Where(x => x.SiteSection.Contains("efd2c88efb1d4ef1ab1e4e17a973a708"));

Query:

(@fsitesection90970*="*efd2c88efb1d4ef1ab1e4e17a973a708*" ) @syssource="Coveo_web_index - 1N-L-MSKUTTA10-Sidley81u3"

From this it looks like the .Where(…) is excluded from the query when .CoveoWhere(…) is used.

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 2, 2016 4:02 PM

That seems very weird to me, I tried something similar on my side and it is working as expected.

Could you share use the whole LINQ expression to see if anything else could interfere and cause your problem?

My other theory is that there is something configured in your search pipeline. Could you check in the Coveo Cloud Administration Console, under the "Search" and then "Pipeline" section, and see if there are some specials rules around? That seems pretty unlikely, but I would try to check it out.

Gravatar for mskutta@onenorth.com

Comment by Mike Skutta, Dec 5, 2016 10:37 AM

Here is a complete example:

        var searchIndex = ContentSearchManager.GetIndex("Coveo_web_index");
        using (var context = searchIndex.CreateSearchContext())
        {
            var results = context.GetQueryable<CoveoSearchResultItem>()
                .Where(x => x.SiteSection.Contains("efd2c88efb1d4ef1ab1e4e17a973a708"))
                .CoveoWhere("phillips");

            var queryResults = results.GetCoveoQueryResults();
            var queryString = string.Format("({0} {1}) {2}", queryResults.Debug.BasicExpression, queryResults.Debug.AdvancedExpression, queryResults.Debug.ConstantExpression);
        }

The result from the queryString variable is: "(phillips ) @syssource=\"Coveowebindex - 1N-L-MSKUTTA10-Sidley81u3\""

I checked the Pipeline you mentioned and I don't see anything that would cause this, but I could be wrong.

Do you think I should open a support ticket?

Thanks, Mike

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Dec 5, 2016 11:05 AM

Yes, I think you will need to open a support ticket. We'll have to dig deeper to understand this behavior.

0 Reply
Ask a question