1

I am updating a search web part and I want to show results from a specific site, I m using "path" to filter results, results are being returned correctly but now query I type in search is getting ignored. for example if I type "zxcvbn" I still get all results from that specific site. If I remove "path" filter I see proper results.

Can I edit search web part query to include "path" and "query" I type in search box?

0

I found that "Keyword" filter also need to be added in the query text.

0

Following are the steps to create a search result webpart from specific site

  • Go to Site settings --> Search Result Sources.

  • On the Manage Result Sources page, click New Result Source. New result source

enter image description here

  • On the Add Result Source page, enter a Name. Select values for Protocol and Type, and click Launch Query Builder. This will open a dialog box.

enter image description here

  • In my scenario, I named the result source Articles, and kept the default values for Protocol and Type. Specify new result source

  • In the Build Your Query dialog box, define the result source.

  • In our scenario, we only wanted search results to come from a particular site within the farm, so in the Query text field, I added the following: {searchTerms?} (contentclass:sts_listitem) path:http:// Specify query for new result source

enter image description here

Now, before we move on, let me break down what I entered:

  • {searchTerms?} In my result source, I wanted to include the words that users type in the query box whey then search for something. Obviously I have no way of knowing what users will type, so I added the query variable {searchTerms?}
  • (contentclass:sts_listitem) This means that only list items will be included in my result source.
  • path:http:// This is the path to the site from where I wanted search results to come from.
  • Test that the result source is working correctly by clicking on the TEST tab, and then Show more. Test result source Click OK to close the dialog box, and then Save.

How to configure the Search Results Web Part to use a new result source - By default, the Search Results Web Part is used on the search results page. In order to configure the Search Result Web Part, you have to navigate to the search results page.

  • On your Search Center home page (the default URL to this page is /Pages/default.aspx), enter a query in the search box, and press Enter.

In my scenario, I entered search configuration. Enter query on search page

  • When you press Enter, you will be taken to the to the search results page (the default URL to this page is /Pages/results.aspx).

Remember, by default you’ll get search results from the entire SharePoint farm. To change this so that only search results from your newly created result source are returned, here’s what you should do:

  • On the search results page, click the Settings menu --> Edit Page. In the Search Results Web Part, click the Web Part Menu, and then Edit Web Part. Edit Web Part

    • In the Web Part tool pane, click Change query. This will open a dialog box. Change query in Web Part tool pane

    • In the dialog box, from the Select a query menu, select your newly created result source.

    • In my scenario, I selected the Articles (Site Collection) result source. Select new result source

    • Click OK in the dialog box, OK in the Web Part Tool pane, and then save the page. To verify that the configuration is working, enter a query.

Reference: How to configure the Search Results Web Part to use a new result source in SharePoint 2013

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.