次の方法で共有


Walkthrough on how to display Search Results filtered on a specific Content Source

 

One of the things you may wish to do if you have multiple content sources is to limit a search result to a specific Content Source. For example I have created a BCS connection to a database table containing a list of products from the sample database Adventureworks product table. When I search, I only want to see results from the products table, like below.

 

 The first thing we would need to do is setup a content Source. For this example, I had previously created a BCS connection to the Adventureworks product table. Now I will create a search content source to point to this BCS connection. When I create a new content source on the search administration page and select BCS Service, a list of external data sources display. In this example I selected my Adventureworks data source.

When I am done it displays here in my content source list. I will need to do a full crawl to populate the index with items.

 Next, I will want to create a Result Source.  A Result Source will allow me to create a scope, or a subset of the crawled content to only return my BCS content source data. in the snapshots below I created a result source called AWResultSource. Note that I have created this result source at the search application level. this allows me to leverage the result source from any site collection. I could also create this same kind of filter at the result page or site collection level which we will see later in this blog.

  

 On the new Result Source page I have chosen "Local SharePoint" and "SharePoint Search Results" and then I will select "launch Query Builder". This will bring up the page to build the actual filter. When I first go to select my property from the property filter, the content source property does not show up. I needed to select "Show all managed properties".

  

 Now I select the ContentSource property, choose Manual value, and enter the name of the content source I created earlier. On the right, you will get a sample of the results to make sure you are on track. If you get a nasty message about not being able to show a preview, you will need to turn on the "Search Server Webpart and properties" feature in site settings for the admin site.

 

The feature name:

 At this point, I have a content source to index the content, and I have a result source to filter search results for the content.

 

Now I will add it to a search center site. The rest of this blog is focused on modifying the search center site collection.

For your reference, go to the Site Settings page for your search center and select "Manage Result Sources". You will note that the Result Source I created above is in the list. If I had wanted to, I could have just added it here and it would be available for this site collection.

 At this point I need a page to show the filtered results with. This is the interesting part, the settings for the filter to only show the results for the content source is part of the results page. Now lets create the page. Go to the Pages library under Site Contents for the search center site. Select Files, New Document, and then Page. Note that the page layout is a Search Results page layout. choose a name and save. In the screenshot below I created a page called awresultpage.

Now we will edit the page to set our filter. Edit the page and choose edit the webpart for the Search results webpart. in the "Properties for Search Results" section, select change query.

 

 For "Select a query" choose the result source. In this case it would be the AWresultSource we created earlier. This will set the filter on the results we want. Again I should see a search result preview. Note that I could have set the result source filter right here instead of at the service application level. You have lots of options for the visibility level for returning a subset of the crawled index.

 

The last thing I need to do is to modify the Search Settings page under site settings to show the menu item on the search page. Here I will add a link under Configure Search Navigation.

 The link points to the results page I created.

Now when I go to the search page, I see products as a menu option. and when I click it, I see the results for the content source.

 

Comments

  • Anonymous
    June 11, 2014
    This is setup almost the same as what I'm trying to do, except that out of all the data that was crawled, I only want to be able to search on lets say folders that begin with DEV.  How would I do this so I don't get items out of folders that begin with UAT?
  • Anonymous
    July 01, 2014
    Hi, I am trying to achieve the same thing: this time, the source is a publishing subsite under root i.e: Root Site is: http://mysite:7070/ and subsite URL is http://mysite:7070/Resource. The resource sub site has a page library and  items in the page library. I am trying to limit the search to the page library in the subsite Resources but I have not got how to do it. Please advise: zombiro@technobrainltd.com