• How to add refiners to your search results page in SharePoint 2013

    This is a blog post in the series, “Set up a Search Center in SharePoint 2013”. 

    In the previous blog post, I showed you how to identify refiners, and told you about refinable managed properties. In this post you’ll learn:

     

    How to map a crawled property to a refinable managed property
    In my Search Center scenario, I knew that I wanted to use the following refinable managed properties:

    Refiner to use Refinable managed property
    Manager RefinableString01
    Internal Writer RefinableString02
    Editor RefinableString03
    Content Type RefinableString04
    Requested Publish Date RefinableDate01

    The procedure to map a crawled property to a refinable managed property is the same for all refiners. In the procedure below, I’ll show you how you can do this. As an example, I’ll show you how I mapped the crawled property that represents Internal Writer to the RefinableString01 refinable managed property.

    1. On your Search Center, on the Site Settings page, select Search Schema.

    Selece Search Schema from Site Settings page

    1. In the Managed property field, type the name of the refinable managed property to which you want to map a crawled property, and then click the arrow button.

      In my scenario, I typed RefinableString01.

    Enter refinable managed property name

    1. From the Property Name field, select Edit/Map Property.

    Edit/Map Property

    1.  On the Edit Managed Property page, click Add a Mapping.

    Add a mapping to refinable managed property

    1. In the Crawled property selection dialog box, use the Search for crawled property name field to search for the crawled property that you want to map to this refinable managed property.

      In my scenario, I knew that I wanted to use the site column called Internal Writer. Crawled properties don’t contain spaces, so I left the space out and entered InternalWriter.

    Search for crawled property

             Two crawled properties were found: ows_q_USER_Internal_Writer and ows_Internal_Writer.

    Two crawled properties found

    If you now look like a big question mark, trust me, I understand your confusion. This part is quite tricky. There are actually two crawled properties (very strange since we only have one Internal Writer site column), so which one should you choose to map to the refinable managed property?

    OK, let's take a closer look at what’s going on. The difference between the two crawled properties is the prefix. One has a ows_q_USER_ prefix, and the other ows_. 
    Now here’s the important part: When mapping a crawled property to a refinable managed property, you should select the crawled property with the ows_ prefix!

    In another blog post I talk about the naming convention for crawled and managed properties. For more information, see From site column to managed property – What’s up with that?

    1. Select the crawled property with the ows_ prefix, and click OK.

      In my scenario, I selected ows_Internal_Writer.

    Select crawled property with ows_ prefix

    On the Edit Managed Property page, notice that the crawled property has been added to the Mappings to crawled property field.

    1. In the Alias field, enter a name for the refiner.

      In my scenario, I entered InternalWriter.

    Enter an alias

    It's important to understand that the alias that you enter here is not the refiner name that will be shown on your search results page. This alias is meant to make your life a bit easier when you’re configuring refiners in the Refinement Web Part (I’ll show you how to do this in the procedure below). Remember, you can't change the name of the refinable managed property, so when you do the configuration, you’ll have to deal with quite a few refinable managed properties that have similar names; RefinableString01, RefinableString02 etc.  So the alias is a good reminder of which value you mapped to the property.

    1. To finish the mapping, click OK.

    Finalize mapping

    I repeated the steps from the procedure above for the remaining four refiners. The screenshots below show my final result.

    The mapped date refiners

    The mapped string refiners

     

    How to initiate a reindexing of a list or library
    When you’ve mapped all the rfinable managed properties that you want to use, you have to do a reindexing of your list or library. I showed you how to do this in a previous blog.

     

    How to configure the Refinement Web Part to use custom refiners
    By default, the Refinement Web Part is included on the search results page. In the previous blog post I showed you how to configure the Search Results Web Part to use a new result source. The two refiners Author and Modified date were also displayed. 

    Default refiners displayed

    To display custom refiners, here’s what you should do:

    1. On the search results page, click the Settings menu, and then click Edit Page.
    2. In the Refinement Web Part, click the Web Part Menu, and then click Edit Web Part.

    Edit Refinement Web Part

    1. In the Web Part tool pane, click Choose Refiners.

    Choose refiners

    1. In the Selected refiners section, select the refiners that you don’t want to display on your search results page, and click Remove.

      In my scenario, I removed all the default refiners.

    Remove refiners

    1. In the Available refiners section, scroll down and select a refinable managed property.

      In my scenario, I selected RefinableString1. This is the refinable managed property that I mapped to the crawled property ows_Internal_Writer. Notice that sample values are shown (a good sign that we’re on the right path), along with the alias InternalWriter.

    Select a refinable managed property

    1. Click Add.

    Add refinable managed property

    This moves the RefinableString01 property over to the Selected refiners section. When a refiner is moved over to the Selected refiners section, additional configuration options are shown (I'll go through them in steps 10 and 11).

    Additional refiner configuration options

    1. Repeat steps 5 and 6 to add all the refiners that you want to use on your search results page.

      In my scenario, I added the five refinable managed properties I configured in the previous section. 

    All selected refiners

    1. To preview the refiners, click Preview Refiners.

    Preview refiners

    1. To change the display order of refiners, select the refiner you want to move, and then click the Move up or Move down button.

      In my scenario, I selected RefinableString04 (notice the Alias name), and selected Move up until it was the first property in the Selected refiners section.

    Move refiner up

    1. To enable users to select multiple refiner values, from the Display template menu, select Multi-value Refinement Item.

    Select Multi-value Refinement Item

    I clicked Preview refiners again, and verified that the ContentType refiner (RefinableString04) was displayed first, and that it had checkboxes that would enable users to select multiple refiner values.

    I repeated this step for the refiners RefinableString01, RefinableString02 and RefinableString03.

    But I wasn’t quite satisfied with the way my RefinableDate01 refiner was displayed. Remember, this refiner represents Requested publish date. By default, the refiner values are shown in a list, which makes it difficult for users to see the date range.

    Default display of date refiner

    To display the refiner values in a more user friendly way, in the Refinement configuration dialog box, from the Display template menu, I selected Slider with bar graph. In the Dates section, I selected Last day, week, month, six months and year.

    Configure date refiner to display as slider with bar

    When I now previewed my refiners, the values for the Requested Publish Date refiner (RefinableDate01) were nicely displayed as a graph.

    Date refiner displayed as slider with graph

    But there was one more thing that I had to improve: the refiner display names. RefinableString01, RefinableString02 etc. does not make much sense to users.

    1. To change the refiner display name, in the Display name field, enter the name you want to be displayed for each refiner.

      In my scenario, for the RefinableString04 refiner, I entered Content Type.

    Change refiner display name

    Repeat this step for all your refinable managed properties.

    1. To save the configurations, click OK in the Refinement configuration dialog box, and then OK in the Web Part tool pane.
    2. Save the page.

      In my scenario, the five refiners were now nicely displayed on the search results page.

    Refiners configured

    However, there was one small detail that would make the refiners even better.  Right now users couldn’t see any numeric details for the refiner values. For example, I could see that I (Bella Engen) was a writer of articles that had to do with search configuration, but I couldn’t see how many articles.

    Refiner counts not displayed

    To see this information, I need to add counts to the refiner values.

     

     

    How to add counts to refiner values
    To add counts to refiner values, you’ll have to edit a display template. When you work with display templates, you'll make life a lot easier for yourself if you map your network drive. By doing this, you’ll be able to work with display templates from Windows Explorer. I describe how you can map your network drive in this blog article.

    1. In your mapped network drive, go to Display Templates --> Filters.
    2. To add counts to refiners where it’s only possible to select one refiner value at a time, open the HTML file Filter_Default. To add counts to refiners where it’s possible to select multiple refiner values, open the HTML file Filter_MultiValue.

      In my scenario, I had configured the refiners so that users would be able to select multiple refiner values, so I opened the file Filter_MultiValue.
    3. Change the value for ShowCounts to true.

    Edit display template to show counts

    1. Save the file.

    To verify that refiner counts are displayed, enter a query in your search center.

    In my scenario, I could now see that I (Bella Engen) was the writer of 5 articles that had something to do with search configuration. Nice!

    Refiners with counts

     

    Next blog article in this series
    How to add a custom search vertical to your search results page

     

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

    This is a blog post in the series “Set up a Search Center in SharePoint 2013”. 

    In the previous blog post, I showed you how to create a Search Center Site Collection and enable crawling of your content. In this post you’ll learn:

     

    How to turn off versioning for the Pages library
    If you don’t want to check pages in and out when you configure the Search Results Web Part, you can turn off versioning for the Pages library.

    To turn off versioning for the Pages library:

    1. Go to Site settings --> Site contents.
    2. On the Site Contents page, click the Pages library.
    3. In the Pages library, click the LIBRARY tab and then Library Settings.
    4. On the Settings page, click Versioning settings.
    5. On the Versioning Settings page, in the Content Approval section, for Require content approval for submitted items, select No.
    6. In the Document Version History section, for Create a version each time you edit a file in this document library, select No versioning.
    7. In the Require Check Out section, for Require documents to be checked out before they can be edited, select No.

    Turn off versioning for the Pages library

     

    Why you should consider creating a result source for your Search Center
    A result source specifies where your search results can come from.

    For example, in my scenario, I did not want search results to come from all sites within the SharePoint farm. I only wanted search results from one specific site within the farm.

    The default result source in a Search Center returns search results from the entire SharePoint farm. If you want search results from the entire SharePoint farm, you can skip to the next blog post in this series.  However, if you want search results from only a sub set within your SharePoint farm (in my scenario, one specific site), you should create a result source.

     

    How to create a result source
    Depending on your permission level, you create a result source on three levels:

    Permission level Where the result source will be added
    Search service application administrator To all site collections within the farm
    Site collection administrator To all sites within a site collection
    Site collection owner To a single site

    To save space, I will only show you how to create a result source as a Site collection administrator.

    1. Go to Site settings --> Search Result Sources.
    2. On the Manage Result Sources page, click New Result Source.

    New result source

    1. 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.

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

    Specify new result source

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

      Remember, in my scenario, I 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://<path>

    Specify query for new result source

    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?} By the way, you can tell it’s a query variable because it’s enclosed in curly brackets.  When users enter a query, this query variable will be replaced by the words the users have typed in the query box. The question mark at the end of the variable means that if no words have been entered, the variable should be ignored.
    • (contentclass:sts_listitem)  This means that only list items will be included in my result source.
    • path:http://<path>   This is the path to the site from where I wanted search results to come from.  
    1. Test that the result source is working correctly by clicking on the TEST tab, and then Show more.

    Test result source

    1. In the {searchTerms} field enter Query words to simulate a query entered by a user, and then click Test query.

      In my scenario, I entered search configuration.

    Test specific query for result source

    Notice that 52 results were returned (I will tell you why this is kind of cool in the next section…).

    1. Click OK to close the dialog box, and then Save.

    So now that we have a result source for the Search Center, we can move on to configuring the Search Results Web Part to use the new result source.

     

    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.

    1. On your Search Center home page (the default URL to this page is <site>/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 <site>/Pages/results.aspx).

    In my scenario, 1,051 search results were returned.

    Default search results showing 1,051 results

    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:

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

    Edit Web Part

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

    Change query in Web Part tool pane

    1. 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

    1. 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.

      In my scenario, I entered search configuration.

    Final search results with new result source

    52 results were returned, which is the same number of items that was returned when I tested the query in the result source configuration. Cool, don’t you think?


    Now that the Search Results Web Part displays the search results we are interested in, the next step is to make it easier for users to filter these search results. To do this, we'll use refiners, which is the subject of the next blog post. 

     

    Next blog post in this series
    Plan to use refiners on a search results page

  • Stage 6: Upload and apply a new master page to a publishing site

    This is a blog post in the series “How to set up a product-centric website in SharePoint Server 2013”.  In this series, I'll use data from a fictitious company called "Contoso" to show you how to use search features to set up a website based on product catalog data.
    Note: Most of the features described in this series are not available in SharePoint 2013 Online.

    For an overview of the blog posts in this series, go to How to set up a product-centric website in SharePoint Server 2013.

     

    Quick overview

    As described in Stage 5: Connect your publishing site to a catalog, we connected the publishing site to our catalog. When we connected, SharePoint Server 2013 automatically created some pages for us, on which some search results where shown. These pages all have the standard SharePoint look, so now it is time to give it a "Contoso look".

     

    In this blog post, we'll learn:

     

    Note: This blog post will not cover how to create a master page. It will only cover how to upload and apply an already finalized master page file and other design files that are stored locally on my computer. These files are not available for download.

    For information about how to create a master page, see Overview of Design Manager in SharePoint 2013 and How to: Convert an HTML file into a master page in SharePoint Server 2013.

    Start stage 6

    About the master page

    When visitors browse our Contoso site, they'll see different content on different pages. The displayed content is a combination of a master page and page layouts.

    A master page defines the common layout and interface that you see on all your webpages, such as logo, title and navigation menu.

    Layout and interface for the individual pages, such as the home page, or the page that displays Audio products, are handled by page layouts. I'll talk more about them in later blog posts.

    SharePoint page model

     

    In previous versions of SharePoint, you had to design master pages in ASP.NET. These master pages also had to include SharePoint specific markup, such as controls and content placeholders.

    In SharePoint Server 2013, you can create a master page in HTML format, and SharePoint Server 2013 will convert this into an ASP.NET page for you.  This means that when you design your master page, you can do this in your favorite HTML editor, focus on HTML, CSS and JavaScript, and you don't have to worry about ASP.NET or SharePoint-specific markup.

    When you add an HTML master page to SharePoint Server 2013, an associated ASP.NET master page will be automatically created.  Because the two files are associated, any changes you make to the HTML master page will be automatically updated in the associated ASP.NET master page .

    For more information, see Overview of the SharePoint 2013 page model.

     

    About the Master Page Gallery

    In our scenario, we have an HTML master page and some design assets, such as a CSS file and images, that we want to upload and apply to our Contoso site. All these files are stored on my local computer.

    SharePoint expects to find design files in the Master Page Gallery, so this is where we should upload the files. To get to the Master Page Gallery, go to Site Settings --> Master pages and page layouts.

    Master Page Gallery

    You can use the Upload Document button to upload a single file to the Master Page Gallery. However, using this button every time you want to add a document can be somewhat cumbersome. To make life easy for yourself, you can map your network drive. This will enable you to drag and drop files into the Master Page Gallery with Windows Explorer.

     

    How to map your network drive

    1. From Settings menu, select Design Manager

    Select Design Manager

    1.  On the Design Manager Welcome page, click 3. Upload Design Files.

    Upload Design Files

    1. On the Upload Design Files page, copy the URL to your design files.

    URL to Master Page Gallery

     

    Note: The next steps will vary depending on your computer's operating system. My computer is running Windows 8, so I will show you how to map your network drive from Windows 8.

    1. Open Windows Explorer. Right click on Network, and select Map network drive.

    Map Network Drive

    1. In the Folder field, paste the URL that you copied in step 3. Click Finish.

    Finish mapping network drive

    1. An explorer window with your Master Page Gallery content opens.

    Master Page Gallery in explorer

     

     

     How to turn off versioning for the Master Page Gallery

    In our scenario, I am not using SharePoint workflows for approval. My files have already been approved, so before I upload a new master page, I want to turn off versioning for the Master Page Gallery.

    To turn off versioning for the Master Page Gallery:

    1. On the LIBRARY tab, click Library Settings.
    2. On the Settings page, click Versioning settings.
    3. On the Versioning Settings page, in the Content Approval section, for Require content approval for submitted items, select No.
    4. In the Document Version History section, for Create a version each time you edit a file in this document library, select No versioning.
    5. In the Require Check Out section, for Require documents to be checked out before they can be edited, select No.

    Turn off versioning

     

    Now we're ready to upload a new master page. 

     

    How to upload a new master page

    Because we have mapped our network drive, uploading a new master page becomes extremely easy. Simply drag and drop the file into your Master Page Gallery.

    Drag and drop design files

     

    If you have any associated design files, such as CSS files or images, you can drag and drop these into the Master Page Gallery as well.

    In SharePoint, refresh the Master Page Gallery page to see that the new HTML master page has been added. However, note that an associated ASP.NET master page has not yet been created.

    HTML master page is added

     

    Because we dragged and dropped the HTML master page into the Master Page Galley, the content type associated with the file is Design File. For SharePoint Server 2013 to create an associated ASP.NET master page, we have to change the content type for the newly uploaded HTML master file. This is done by changing the file properties.

    To change the file properties:

    1. On the Master Page Gallery page, select the newly uploaded master page, and then click Edit Properties.

    Edit Properties of file

    1. In the Content Type section, select HTML Master Page.
    2. In the Compatible UI Version(s) section, select 15.

    Set properties of file

    On the Master Page Gallery page, we can see that an associated ASP.NET master page has been created.

    ASP.NET file created

     

    We are now ready to apply our new master page.

     

    How to apply a new master page

    To apply a new master page:

    1. From the Site Settings page, click Master page (under Look and Feel).
    2. From the Site Master Page section, from the Specify a master page to be used by this site and all sites that inherit from it, select the newly uploaded master page. In our scenario, this is ContosoElectronicsMaster.

    Apply new master page

     

    By clicking on the Audio page, we verify that our new master page is now being used.

    New master page in use

     

    The next step is to start working on the page layouts.

     

     

     

    Next blog article in this series
    Stage 7: Upload page layouts and create new pages in a publishing site

     

     

     

    Additional Resources