Share via


SharePoint 2013 Search: Even Better Best Bets with Exact Matching

First, full credit goes to Mikael Svenson and Petter Skodvin-Hvammen for the original solution.  This blog details a small modification to Mikael's "Better Best Bets" blog found here: https://blogs.msdn.com/b/mvpawardprogram/archive/2014/07/21/better-best-bets-with-lists-in-sharepoint-2013.aspx.

Today's blog is a bare-bones, step-by-step process modifying the Better Best Bets solution to do exact matches on keywords.  The "Better Best Bets" solution can only do "contains" matches on keywords since the keyword column type is a taxonomy and has taxIds in the indexed content preventing exact matches.   

From the "Better Best Bets" blog:

If you have multi-word trigger terms, make sure all words are pretty good/unique to avoid unwanted partial matches. Or stick with the out of the box query rule matching with a promoted result instead.

 From <https://blogs.msdn.com/b/mvpawardprogram/archive/2014/07/21/better-best-bets-with-lists-in-sharepoint-2013.aspx>

 

The steps below detail how to use SharePoint lists to manage best bets which will do exact matches on multi-value keywords.  For simplicity, the example below doesn't included the Date properties like the "Better Best Bets" solution, but they can be added and used just like they were previously.

This solutions uses two SharePoint lists.  The first list contains all the keywords.  The second list has a lookup column using the keywords in the first list.  This is required so multi-valued data will be preserved during content processing and the exact match operator will match the multi-valued keywords correctly.

From a non-search site create a List that will be a source for the individual keywords.

  1. Create Site Column for Keyword Source List
  1. Site Settings > Site Columns > Create
  1. Name: ebbbKeywordSource
  2. Type: Single line of text
  3. Put this site column into:
  1. New Group: Even Better Best Bets
  • Require that this column…: Yes
  • Enforce unique values: Yes
  • OK
  • Create Content Type for Keyword Source List
  1. Site Settings > Site content types > Create
  1. Name: EBBBKeywordSource
  2. Select parent content type…: List Content Types
  3. Parent Content Type: Item
  4. New Group: Even Better Best Bets
  5. OK
  • Site Content Types > Site Content Type (Even Better Best Bets Keyword Source)
  1. Select Title column
  1. Select Hidden
  2. OK
  • Add from existing site columns
  1. Select ebbbKeywordSource
  2. Click Add
  3. OK
  • Create a Custom Keyword Source List
  1. List name: Even Better Best Bets Keyword Source List
  2. Select List (Even Better Best Bets Keyword Source List)
  1. List tab > List Settings
  2. Advanced Settings
  1. Allow management of content types: Yes
  2. Allow items from this list to appear in search results: No
  3. OK
  • Add from existing site content types
  1. Select EBBBKeywordSource
  2. Click Add
  3. OK
  • Click Change new button order and default content type
  1. Content Type: Item
  1. Uncheck Visible
  • Content Type: EvenBetterBestBets
  1. Position from Top: 1
  • OK
  • Views > All Items
  1. Title
  1. Uncheck Display
  • ebbbKeywordSource
  1. Check Display
  • OK
  • Enter Keyword values in ebbbKeywordSource column
  1. Click "new item"
  1. Enter a unique word or phrase
  2. Save
  • Repeat

 

From a non-search site create a List that will reference the Keywords Source List and hold the data used to create the Best Bets.

  1. Create Site Columns
  1. Site Settings > Site Columns > Create
  1. Name: ebbbTitle
  2. Type: Single line of text
  3. Put this site column into:
  1. Existing Group: Even Better Best Bets
  • Require that this column…: Yes
  • Enforce unique values: Yes
  • OK
  • Site Settings > Site Columns > Create
  1. Name: ebbbURL
  2. Type: Single line of text
  3. Put this site column into:
  1. Existing Group: Even Better Best Bets
  • Require that this column…: Yes
  • OK
  • Site Settings > Site Columns > Create
  1. Name: ebbbKeywordsMatch
  2. Type: Lookup
  3. Put this site column into:
  1. Existing Group: Even Better Best Bets
  • "Require that this column…": Yes
  • Get information from: Even Better Best Bets Keyword Source List
  • In this column: ebbbKeywordSource
  1. Allow multiple values: Yes
  • Create Content Type
  1. Site Settings > Site content types > Create
  1. Name: EBBBList
  2. Select parent content type…: List Content Types
  3. Parent Content Type: Item
  4. New Group: Even Better Best Bets
  5. OK
  • Site Content Types > Site Content Type (EBBBList)
  1. Click Title column
  1. Select Hidden
  2. OK
  • Add from existing site columns
  1. Select ebbbKeywordsMatch, ebbbTitle, ebbbURL
  2. Click Add
  3. OK
  • Create Best Bets List
  1. List name: Even Better Best Bets List
  2. Create
  3. Select List (Even Better Best Bets List)
  1. List tab > List Settings
  2. Advanced settings > Allow management of content types: Yes
  3. OK
  4. Add from existing site content types
  1. Select EBBBList
  2. Click Add
  3. OK
  • Click Change new button order and default content type
  1. Content Type: Item
  1. Uncheck Visible
  • Content Type: EBBBList
  1. Position from Top: 1
  • Views > All Items
  1. Title
  1. Uncheck Display
  • ebbbKeywordsMatch, ebbbTitle, ebbbURL
  1. Check Display
  • OK
  • Enter data for Even Better Best Bets List
  1. Click "new item"
  2. Add data for ebbbKeywordsMatch, ebbbTitle and ebbbURL
  3. Save
  4. Repeat
  • SSA Admin > Content Sources > Local SharePoint sites > Full Crawl (or Content Source pointing to your site)
  1. Once crawl has completed, the query spcontenttype:ebbbList will return all items in Even Better Best Bets List
  • SSA Admin > Search Schema > Crawled Properties (or at the desired Tenant level)
  1. Search for ebbb
  2. For each ows_ebbb* field
  1. Uncheck "Include in full-text index"
  • SSA Admin > Search Schema > Managed Properties (or at the desired Tenant level)
  1. Verify fields ebb*OWSTEXT exists for Title and URL with Query and Retrieve properties (not Search) with a mapping.
  2. New Managed Property
  1. Name: ebbbKeywords
  2. Type: Text
  3. Check Queryable
  4. Check Retrievable (optional, good for debugging)
  5. Check Allow multiple values
  6. Add a Mapping
  1. Select ows_ebbbKeywordsMatch
  2. OK
  • OK
  • SSA Admin > Content Sources > Local SharePoint sites > Full Crawl (or Content Source pointing to your site)
  1. Once crawl has completed, the query ebbbKeywords="<keywords>"spcontenttype:ebbbList will return all items in Even Better Best Bets List that match <keywords>. Supports exact match on multivalues.

 

From the Search Center Site

  1. Create Display Template
  1. Search Center > Site Settings > Master pages and page layouts > Display Templates > Search > Item_BestBets.html > Download a Copy > Save as Item_EvenBetterBestBets.html.
  2. Edit Item_EvenBetterBestBets.html
  1. <title>Even Better Best Bets</title>
  2. <mso:ManagedPropertyMapping msdt:dt="string">'bbTitleOWSTEXT':'bbTitleOWSTEXT','bbURLOWSTEXT':'bbURLOWSTEXT'</mso:ManagedPropertyMapping>
  3. Save
  • Display Templates > File Tab > Upload Document
  1. Select file
  2. OK
  3. Save
  • Create Result Type
  1. Search Center > Site Settings > Site Collection Administration > Search Result Types > New Result Type
  1. Name: Even Better Best Bets
  2. Show more conditions
  1. Which custom properties should match: Content Type
  2. (Value): EBBBList
  • What should these results look like: Even Better Best Bet Item
  • Check Optimize for frequent use
  • Save
  • Create Result Source
  1. Search Center > Site Settings > Site Collection Administration > Search Result Sources > New Result Source
  1. Name: Even Better Best Bets
  2. Query Transform: ebbbKeywords="{searchTerms}" spcontenttype=ebbblist
  3. Save
  • Create Query Rule
  1. Search Center > Site Settings > Site Collection Administration > Search Query Rules
  1. Select "Local SharePoint Results" > New Query Rule
  1. Rule Name: Even Better Best Bets
  2. Remove Condition
  3. Add Result Block
  1. Title: Best Bets for "{subject Terms}"
  2. Search this Source: Even Better Best Bets
  3. Items: 5
  4. Click Settings
  1. Select This block is always shown above core results
  • OK
  • Change ranked results by changing the query (hide best bets content and list AllItems.aspx from "default" search results).
  1. Query Text: {searchTerms} -spcontenttype:ebbblist -ListURL:"Even Better Best Bets List"
  2. OK
  • Save
  • Test Best Bets from Search Box