I've got a search results web part which searches for pages in a sharepoint library. I'd like to add a query text that limits the search to only certain URLs, such as 'mysite.com/sites/somepagename'

But I just can't figure out what the field containing the URL is supposed to be.

I've checked the 'Property filter' dropdown and there is no field named 'URL'. Tried using properties with like 'Location' , 'Site' and 'urls' filtering for results that contain 'somepagename' without any success.

How do I filter by URL?

EDIT: Sorry for confusing you guys, it's actually a Search Results web part. Not Content Query.

  • so you want to get this url parameters from the url you are calling? – Gwny Aug 21 '15 at 14:34
  • @uberz91, what made you propose an edit of the post from Content by Query to Content By Search? No information given by the poster supports that change as far as I can see? – Robert Lindgren Aug 22 '15 at 10:43
  • @RobertLindgren because of a few things : he is talking about property filters which most likely refers to managed properties in the content search web part, he is also mentioning that it is searching for some pages which most likely also refers to a content search web part. Also, he wants to write some query text which lead me to believe that he is experimenting with the cswp instead of cqwp. – Akhoy Aug 22 '15 at 11:32
  • Sorry guys, I f'ed up. it's actually a Search Results webpart – Drkawashima Aug 22 '15 at 12:03
  • Now at least we all know the real answer :) – Robert Lindgren Aug 22 '15 at 12:09

The path property should give you what you're looking for - but note that you need to include the whole path, http:// and all.


and you can control whether or not to include subsites with the UrlDepth property

path:"https://sharepointsite.sharepoint.com/mysite"  UrlDepth=1

Will return results from https://sharepointsite.sharepoint.com/mysite only

path:"https://sharepointsite.sharepoint.com/mysite"  UrlDepth=2

Will return results from https://sharepointsite.sharepoint.com/mysite/subsite1, https://sharepointsite.sharepoint.com/mysite/subsite2 etc.

  • In that case my advice would be to use a Content Search web part instead ;-) – Tim Aug 21 '15 at 15:40
  • Please clarify that in your answer if that is the case :) – Robert Lindgren Aug 21 '15 at 18:57
  • Ok - this is serendipitous but the question now says Content Search web part instead of Content Query. 19 hours ago Drkawashima - I'm pretty sure if you add the http:// or https:// prefex you'l start seeing results – Tim Aug 22 '15 at 9:33
  • This works! Thanks (I'm actually using a Search Results webpart, my original post was incorrect. But it works fine for that webpart as well) – Drkawashima Aug 22 '15 at 12:23

Note completely sure if this answers your question, but if you want your Search Results Web Part to only include hits from that site, place your results page in edit mode, and select the "Results" web part for editing, On the right, you will see a button for "Change Query".

Typically by default the Query Text is set to


You just need to adjust to look like

{searchboxquery} Path:{Site.URL}

and now it will only include results from that root site and down.

Another option is to use the "Site Title" refiner. If you go into managed properties, you will see one called "SiteTitle". You will have to update this to map to the crawled property of "ows_SiteName".

Once you do that, you can add "Site Title" as a refiner and users can then filter their results down based on which SITE the item was found.

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.