How to limit search results to the current and sub-sites in SharePoint 2013
Here is a quick hint for the use case where you want to position a search box and/or results to only show results that may reside in the current site or all sites below it.
#1 – Create a result source at whatever level you wish. If you set it at the search service level, you can use this results source over and over throughout the entire farm. It can also be set for a site collection or an individual site. You need to figure out at what level do you want to reuse it. Just copy the default result source and modify it as follows.
#2- Use the query transform capability to modify the results source by adding the following modification. Add the property path contains “This site”. It will look like this in the query text
Since you are specifying “contains”, it will include the current site and all subsites since all subsites will contain the path of the parent. All other results not in or below the current site will be excluded because they will not have this path.
This screen shot shows the whole thing. I made this at the site collection level. Had I done it at the farm (search service) level, it can be used anywhere in the farm.