I have the same unanswered issue as in :

Using a Search Result Source to limit to current site

According to Microsoft's documentation at http://technet.microsoft.com/en-us/library/jj683123(v=office.15).aspx, the {Site.URL} variable returns the "URL of the site from where the query was issued." Unfortunately, that is not what seems to be happening.

So, If this query: {searchTerms}{Site.URL} doesn't work, something else must be wrong ?!

  • wander if there was any OOTB solution for that at the end. – eyal barak Feb 28 '17 at 9:32

The query should be {searchTerms} Path:{Site.URL}, but this will still only reference the content in the site with the WebPart.

When Microsoft is use the description

URL of the site from where the query was issued.

then it's due to them expecting you to configure a WebPart file and reuse that in many sites which without the token would require you the edit the WebPart after inserting it.

One solution (not tested) might be do change the initial search page to not contain the search WebPart, but instead some javascript which takes the original Url in document.referrer, remove page name and /Pages and passed that in a QueryString like OrigSite to the new Real search page along with the original k query string. Then you can use {searchTerms} Path:{QueryString.OrigSite}

| improve this answer | |
  • Sorry I typed the body of the question wrong. As stated in the title of the question, {searchTerms} Path:{Site.URL} is also what I used, and is not giving the results of the Site where the query is done, but of the Site where the results web part is executed. – oysterhoys Jun 7 '15 at 7:09
  • See updated answer – Per Jakobsen Jun 7 '15 at 12:23
  • Thanx for helping me on this issue. I hoped there would be a more "out of the box" solution. I would expect there to be one. With the default search center that MS automatic provides in SP2013 Online in a seperate site-collection at <tenant>/search it is working exactly the way as I'm looking for. Using the standard search-box at any page directs you to the search center elsewhere, and still showing the results relating to the original site. But there that "referrer" is probably hardcoded. – oysterhoys Jun 8 '15 at 11:54

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.