different u parameter values in sharepoint online search

Hi I have set up current site context in search by using u={contexturl}, which gives url of current contextual site.  Is there a way I can set it up to current site collection context ?

For e.g. within sub site when I turn dropdown options on for search box, I need to default "Everything" to current site collection. I do not want to use default results.aspx as it redirects users to tenant level thus loosing context of current site from where they searched. We have hidden default sharepoint global navigation so they click on site logo to go back to site, in this case clicking on site logo from results.aspx page it takes them to tenant level site which we do not want.

To solve above problem, I tried to use same local page within site for current site context and site collection context see below.

Every new site gets its own copy of currentsubsite/_layouts/15/osssearchresults.aspx?

Using this page on current site to get current context of current site 

For e.g.: currentsubsite/_layouts/15/osssearchresults.aspx?u={contexturl} -- by clicking on site logo on this page it takes users back to local site from where they searched. -- This works fine for "This Site" scope

Using same page to manually set up current site collection context :

 for e.g.: currentsubsite/_layouts/15/osssearchresults.aspx?u=hardcoded url of current site collection. This works fine for "Everything" scope as we only want to search within site collection, also this lets user go back to their current sub site by clicking on site logo from where they searched -- Is there a way I can use something similar to {contexturl} for u parameter which automatically resolves to current site collection ?


Hi DellT,


You can refer to the following table.

Search Core Results Query string parameters

K Search keywords. This should be the URL-encoded value that the user typed in, including the full-text query and any managed properties.
S The scope to query. This is the scope from the scopes drop-down list. To specify multiple scopes to query, you can separate them with a comma (which when URL-encoded become %2c).
U The beginning of the site property. This is used primarily with the contextual scopes, but can be useful if you want to constrain the results to a particular site or area, and do not want to define a scope.
V The default ordering (or view). The valid options are relevance and date.
Start The page number to show. This option is useful if you want to display the initial set of results and turn the display over to Search Core Results and a search results page after the first set of results.


For more information, please refer to our SharePoint Forum on MSDN as suggested above.



If you feel a reply works for you, please kindly vote or mark it as it will be beneficial to other community members reading this thread.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.


Question Info

Last updated June 27, 2019 Views 1,424 Applies to: