Gravatar for awillia2@gmail.com

Question by alexis williams, Aug 26, 2014 11:39 AM

disjunctionExpression

When querying with outlook we get back the following suggestion:

Did you mean: (outlook NOT @objecttype=Reply) OR ((@objecttype=Question [[@sfquestionid] oulook]) NOT @objecttype=Question)"

Here's our code below:

Current code:

$('.CoveoPanel').on('buildingQuery', function(e, args) {
  //managing the retrieval of KB objects based on the user locale, disregarding locale for other object types.
  args.queryBuilder.advancedExpression.add('(@sflanguage =={!JSENCODE(userLocale)} OR NOT @sflanguage) OR (@sfobjecttype=("Idea","KnownIssueC","Question","Reply"))');

  var tab = $('.CoveoSearchInterface').coveo('state', 't');
  if (tab != "Answers" && tab != "All") return;
  var builder = new Coveo.Ui.ExpressionBuilder();
  args.queryBuilder.expression = builder;
  var expr = $('.CoveoSearchInterface').coveo('state', 'q');
  args.queryBuilder.expression.add("("+expr+" AND NOT (@objecttype=Reply)) OR (@objecttype=Question [[@sfquestionid] "+expr+" ]) AND NOT (@objecttype=Question)");
});

Here was the suggested code from Eric

Suggested code:

$('.CoveoPanel').on('buildingQuery', function(e, args) {
  //managing the retrieval of KB objects based on the user locale, disregarding locale for other object types.
  args.queryBuilder.advancedExpression.add('(@sflanguage =={!JSENCODE(userLocale)} OR NOT @sflanguage) OR (@sfobjecttype=("Idea","KnownIssueC","Question","Reply"))');

  var tab = $('.CoveoSearchInterface').coveo('state', 't');
  if (tab != "Answers" && tab != "All") return;
  var expr = $('.CoveoSearchInterface').coveo('state', 'q');  
  args.queryBuilder.disjunctionExpression.add(args.queryBuilder.advancedExpression.build() + ' AND (@objecttype=Question [[@sfquestionid] "+expr+" ]) AND NOT (@objecttype=Question)');
  args.queryBuilder.advancedExpression.add("NOT (@objecttype=Reply)");
});

Show contextual results appears to work ok, but removing show contextual results always returns the same result set with this query:

"((NOT @sfkbislatestversion OR @sfkbislatestversion=="True") (NOT @sfknownissuecpublishedc OR @sfknownissuecpublishedc=true)) ((@sflanguage ==en_US OR NOT @sflanguage) OR (@sfobjecttype=("Idea","KnownIssueC","Question","Reply"))) AND (@objecttype=Question [[@sfquestionid] "+expr+" ]) AND NOT (@objecttype=Question)"
Gravatar for slangevin@coveo.com

Comment by Simon, Apr 30, 2015 8:23 AM

I know this has been a long time but I fail to see the issue here.

1- Why is your "did you mean" proposing a field query? The query is an advanced expression according to your query builder, so I do not believe that Did you mean would correct it. It should only do it with Basic expression.

2- About your last query. What exactly is supposed to happen with it? What is the expected outcome vs what is returned?

0 Reply
Ask a question