0

I have a query rule like this: http://screencast.com/t/ecFYmwDyhk3

More link goes to the following url

 https://be-prpsp029.com/search/Pages/My-Search-Results.aspx?k={subjectTerms}

This works perfectly fine for keywords with one workd

However, when the keyword is two words, the subject terms goes with %20 between the words, and therefore nothing is found:

http://screencast.com/t/tySgbryT

  • Just in case you didn't know, the %20 is the way HTML encodes spaces. So while the URL will have "?k=John%20Doe", it should still be "John Doe" outside of an HTML encoding (I mean, go on google and search somthing with spaces, it'll have the %20" or something similar). – Brandon C. Jun 18 '14 at 9:29
  • I know that, but check the 2nd screenshot, sharepoint puts the %20 on the textbox, and then search wont return any results. – Luis Valencia Jun 18 '14 at 9:32
  • Quick question before I provide my answer, just to make sure I give a correct one. How are you writing your query? Are you creating it through code by yourself, or just through the application? – Brandon C. Jun 18 '14 at 9:37
  • I do it through site settings, search query rules, launch query builder. query is {subjectTerms} Author:{User.Name} Path:be-prpsp029.com, see screenshot here: screencast.com/t/zdcdED9vZIdJ – Luis Valencia Jun 18 '14 at 9:41
  • is My-search-results.aspx a page you made by yourself, filtering after querystring? – Gwny Jun 20 '14 at 10:56
1

Could it be that the problem is the way you construct the 'More' Link? You are using {subjectTerms} in the more link, which is the search terms without the original Action term which fired the special Result Block. So the first page is firing the Query Rule, but the More page isn't.

Perhaps using {searchboxquery} in the more link would cause the rule to fire on the second page.

1

The Query Conditions part of the Add Query Rule controls how the {searchboxquery} (the original thing the user typed) gets transformed into {subjectTerms} and {actionTerms}.

Are you using Advanced Query Text Match? And which of the options do you have selected to:

  • Assign the entire query to {subjectTerms}
  • Assign match to {subjectTerms], unmatched terms to {actionTerms}
  • Assign match to {actionTerms}, unmatched terms to {subjectTerms}

In any event I don't think the problem is with the query for your result block, but rather for your query conditions and how "and the" is getting assigned to {subjectTerms}.

PS: Not sure if this counts as an answer, but I would have commented on Fletchonides post, only I don't have enough points to comment. Kinda a catch 22 isn't it.

0

You could use decodeURI() (http://www.w3schools.com/jsref/jsref_decodeURI.asp)

function getUrlVars() {
    var url = window.location.href,
    vars = {};
    url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
        key = decodeURIComponent(key);
        value = decodeURIComponent(value);
        vars[key] = value;
    });
    return vars;
}
  • how can I use it inside a sharepoint content search webpart? or in the query role? – Luis Valencia Jul 18 '14 at 13:32
0

I have posted the answer here:

(explanation its too long to be posted as an answer here) http://www.luisevalencia.com/2014/08/18/fix-double-encoding-bug-aka-sharepoint-display-templates-promoted-results/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.