Gravatar for paldrich@ascedia.com

Question by Paul Aldrich, Jun 6, 2017 7:36 PM

Coveo Did You Mean UI Glitch

Hello,

I am trying to figure out a UI glitch that the client just noticed recently. When I enter certain misspelled words, the Did You Mean feature is executed, but it is not showing results. It appears to be showing the Coveo query itself. For example, go to this page: http://www.subzero-wolf.com/search#q=griel. We are seeing this issue in all environments - QA, Authoring and Production.

It only seems to happen when all characters in the search query are lowercase. If I uppercase the query to be Griel or GRIEL it does not fire the Did You Mean feature. The diagnostic page is all green and I am not seeing any errors that seem specific to this bug in the Sitecore logs. We often see "The cookie "united states#lang" is invalid. It will not be forwarded to the Search API.", although I'm not sure if this is related to this problem.

We are using Coveo for Sitecore V4. The Did You Mean link is rendered like this:

<a class="search-result__link CoveoResultLink" href="#q={{= result }}">{{= result }}</a>

EDIT: It seems like the result variable has double quotes in it but they are not escaped. Do they need to be?

Thanks,

Paul

3 Replies
Gravatar for flguillemette@coveo.com

Answer by François Lachance-Guillemette, Jun 6, 2017 8:12 PM

The DidYouMean does not work properly because you are modifying the `q` part of the query, which is intended to be only what the user enters in the searchbox. The query you see there is everything that is programmatically added to the query and should have instead been put in the `aq` part of the query.

See here for the query parameters and their functions: REST Search API Query Parameters

Gravatar for paldrich@ascedia.com

Comment by Paul Aldrich, Jun 6, 2017 10:19 PM

Hi François,

That does make sense. I'm kind of bewildered though, since we've been using DidYouMean for a while and the q was not changed, I would have expected someone to catch this earlier.

When I use aq the problem does not occur locally, but now I am not sure if DidYouMean is firing correctly. When I enter a misspelled word like 'refrigeratoin" it does not seem to show DidYouMean. I'm not too familiar with DidYouMean and how it is set up on this site.

Is there some way I can tell that DidYouMean is executing but not providing advice for some queries?

Thanks,

Paul

Gravatar for paldrich@ascedia.com

Answer by Paul Aldrich, Jun 7, 2017 8:04 PM

Hi François,

I believe I may have fixed this. I'm not sure if this is what you suggested or the opposite. I commented out the code that does the replace and push and added a line to just push the corrected word. See image attached to review corrections: didyoumeancorrections.png

I've tested this on QA and I see what I would expect: under "Did you mean...", I see "gril" and clicking that word sets up a new query. Entering valid search terms work as expected. I'm a little surprised this worked so well - are there any risks you see with this change?

Thanks,

Paul

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Jun 7, 2017 8:36 PM

Great! This is essentially what I wanted to achieve, although I didn't have the right method :)

I would like that you try a correction with two words, like "outdoor griel" and see if it corrects it to "outdoor grill"

Gravatar for paldrich@ascedia.com

Answer by Paul Aldrich, Jun 7, 2017 8:53 PM

Unfortunately if I enter "outdoor griel" it suggests "gril" (no outdoor). I'm not sure if this because of my change or if never worked this way... How do I make sure it includes additional words? I am researching but not finding much.

If I enter two misspelled words, like "subzoro griel" it gives me two DYM results (one for each word).

Gravatar for flguillemette@coveo.com

Comment by François Lachance-Guillemette, Jun 7, 2017 8:57 PM

What you could do if this:

  1. Get the query entered in the searchbox, if it is empty, use the `q=X` part in `window.location.hash`, store it in, say a `currentExpression` variable.
  2. `currentExpression = currentExpression.replace(wordCorrection.originalWord, wordCorrection.correctedWord)` right instead of the new line you added.

The result of `currentExpression` after the loop should be what the user entered with all the word corrections applied to it.

Ask a question