Gravatar for christopher.gutmanis@aurora.org

Question by cmgutmanis, Jul 23, 2015 3:52 PM

Equality search returning more results than contains search on same field

Hi,

I've got a peculiar situation. I am querying a given field through either a form submission or a deeplink. To account for vagueness in the submission, I am allowing for a partial match, i.e. "neuro" would return items for both "neurology" and "neurosurgery," whereas deeplinking in would imply an exact match, i.e. "neurosurgery" would only match against "neurosurgery".

I'm seeing some rather inexplicable weirdness though - if I submit the form with "Internal Medicine" as my query, I'll do my CONTAINS search and return ~200 results (expected). If I do it as an EXACT match on the same field, I return upwards of 1400, the vast majority of which have nothing even remotely matching in that field. I inspected coveo console just to make sure the traffic mirrored what I was seeing and received the following:

Query (@fspecialtygroups5872=="Internal Medicine") performed by coveo\admin [Sitecore Security Provider for mysite]. 1401 results in 0.453 seconds.

Query (@fspecialtygroups5872*="*Internal Medicine*") performed by coveo\admin [Sitecore Security Provider for mysite]. 217 results in 0.141 seconds.

I'm hitting the same server and the same index and got the same results when querying through the CES Admin tool as well.

Does anyone have any idea what I'm missing here?

Thanks!!

1 Reply
Gravatar for slangevin@coveo.com

Answer by Simon, Jul 24, 2015 7:51 AM

Looking at the field hashing, I believe this is a Coveo for Sitecore solution. This mean that we should be able to grasp the entire query from the browser dev tools. Start by accessing them (f12) and navigating to the network tab. Then try both query again. This should send a POST request. In the header of that request, under the Form Data section, you should see the payload separated in different sections (q, aq, cq, etc…).

"q" is the basic query, so in your case, it should be (@fspecialtygroups5872=="Internal Medicine") for example. this is captured by the CES console. "aq" is the advanced query and is hidden from the console, that might be where you will find the answer to the disparity in results. "cq" is a constant expression. Usually in Coveo for Sitecore, it will contain the source filtering for the website database.

Tell us if you find anything strange by comparing both.
Cheers
Simon

Gravatar for christopher.gutmanis@aurora.org

Comment by cmgutmanis, Jul 24, 2015 10:58 AM

Hi Simon, Thanks for responding.

You are correct, this is a Coveo for Sitecore solution. However, we are using the LINQ provider to perform the queries here, so the only thing that will actually show in the console is the POST action to the controller.

The first query (the one that returns 217 results is var results = context.GetQueryable() .Where(x => x["specialtyGroups"].Contains(query)) .GetResults()

The one that is returning the larger, incorrect result set is var results = context.GetQueryable() .Where(x => x["specialtyGroups"] == query) .GetResults();

Thanks again!

Gravatar for christopher.gutmanis@aurora.org

Comment by cmgutmanis, Jul 24, 2015 11:56 AM

the other thing is that I typed the raw queries in the coveo admin tool directly and was getting the same results.

Gravatar for slangevin@coveo.com

Comment by Simon, Jul 24, 2015 12:01 PM

Ok I see, here is two things you could try.

1- If you take the query @fspecialtygroups5872=="Internal Medicine" and paste it in the search box of the Index Browser (https://onlinehelp.coveo.com/en/ces/7.0/administrator/administrationtool-indexbrowser_menu.htm), does it returns the same amount of results?

2- If you change your code to use the ExactMatch operator mentioned here:

https://developers.coveo.com/display/public/SC201507/Coveo+LINQ+Extensions

Does it return the same thing?

Regards, Simon

Gravatar for christopher.gutmanis@aurora.org

Comment by cmgutmanis, Jul 24, 2015 12:16 PM

Hi Simon,

Sorry, I may have been unclear. I have been pasting the query into the search bar of the Index browser that you suggested and been seeing strange results. I will try the ExactMatch and see what happens - do you know if that also performs a case-sensitive match? That may or may not present issues, depending on how the deeplinks are formatted.

Thanks again

Gravatar for slangevin@coveo.com

Comment by Simon, Jul 27, 2015 6:18 PM

It is not case sensitive.

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Aug 4, 2015 5:04 PM

To further troubleshoot this weird behavior, could you please tell me:

  • The configuration of the @fspecialtygroups5872 field in CES (Configuration > Fields > The right field set). I want to know whether it is facet, multi-value facet, free-text, and sortable.
  • Example values of this field for documents that matches both queries (Details (Under the search result) > Fields > Filter for "@fspecialtygroups5872").

Thank you

Ask a question