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.
For example, if you have the Best Bet Keywords "United", "United States" and "Manchester United", the contains operator and the keyword "United" will match all three. This may be undesired behavior. Having the ability to use the exact match operator, the Keyword "United" will only match the "United" Best Bet Keyword.
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.
- Create Site Column for Keyword Source List
- Site Settings > Site Columns > Create
- Name: ebbbKeywordSource
- Type: Single line of text
- Put this site column into:
- New Group: Even Better Best Bets
- Require that this column…: Yes
- Enforce unique values: Yes
- OK
- Site Settings > Site Columns > Create
- Create Content Type for Keyword Source List
- Site Settings > Site content types > Create
- Name: EBBBKeywordSource
- Select parent content type…: List Content Types
- Parent Content Type: Item
- New Group: Even Better Best Bets
- OK
- Site Content Types > Site Content Type (Even Better Best Bets Keyword Source)
- Select Title column
- Select Hidden
- OK
- Add from existing site columns
- Select ebbbKeywordSource
- Click Add
- OK
- Select Title column
- Site Settings > Site content types > Create
- Create a Custom Keyword Source List
- List name: Even Better Best Bets Keyword Source List
- Select List (Even Better Best Bets Keyword Source List)
- List tab > List Settings
- Advanced Settings
- Allow management of content types: Yes
- Allow items from this list to appear in search results: No
- OK
- Add from existing site content types
- Select EBBBKeywordSource
- Click Add
- OK
- Click Change new button order and default content type
- Content Type: Item
- Uncheck Visible
- Content Type: EvenBetterBestBets
- Position from Top: 1
- OK
- Content Type: Item
- Views > All Items
- Title
- Uncheck Display
- ebbbKeywordSource
- Check Display
- OK
- Title
- Enter Keyword values in ebbbKeywordSource column
- Click "new item"
- Enter a unique word or phrase
- Save
- Repeat
- Click "new item"
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.
- Create Site Columns
- Site Settings > Site Columns > Create
- Name: ebbbTitle
- Type: Single line of text
- Put this site column into:
- Existing Group: Even Better Best Bets
- Require that this column…: Yes
- Enforce unique values: Yes
- OK
- Site Settings > Site Columns > Create
- Name: ebbbURL
- Type: Single line of text
- Put this site column into:
- Existing Group: Even Better Best Bets
- Require that this column…: Yes
- OK
- Site Settings > Site Columns > Create
- Name: ebbbKeywordsMatch
- Type: Lookup
- Put this site column into:
- 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
- Allow multiple values: Yes
- Site Settings > Site Columns > Create
- Create Content Type
- Site Settings > Site content types > Create
- Name: EBBBList
- Select parent content type…: List Content Types
- Parent Content Type: Item
- New Group: Even Better Best Bets
- OK
- Site Content Types > Site Content Type (EBBBList)
- Click Title column
- Select Hidden
- OK
- Add from existing site columns
- Select ebbbKeywordsMatch, ebbbTitle, ebbbURL
- Click Add
- OK
- Click Title column
- Site Settings > Site content types > Create
- Create Best Bets List
- List name: Even Better Best Bets List
- Create
- Select List (Even Better Best Bets List)
- List tab > List Settings
- Advanced settings > Allow management of content types: Yes
- OK
- Add from existing site content types
- Select EBBBList
- Click Add
- OK
- Click Change new button order and default content type
- Content Type: Item
- Uncheck Visible
- Content Type: EBBBList
- Position from Top: 1
- Content Type: Item
- Views > All Items
- Title
- Uncheck Display
- ebbbKeywordsMatch, ebbbTitle, ebbbURL
- Check Display
- OK
- Title
- Enter data for Even Better Best Bets List
- Click "new item"
- Add data for ebbbKeywordsMatch, ebbbTitle and ebbbURL
- Save
- Repeat
- SSA Admin > Content Sources > Local SharePoint sites > Full Crawl (or Content Source pointing to your site)
- 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)
- Search for ebbb
- For each ows_ebbb* field
- Uncheck "Include in full-text index"
- SSA Admin > Search Schema > Managed Properties (or at the desired Tenant level)
- Verify fields ebb*OWSTEXT exists for Title and URL with Query and Retrieve properties (not Search) with a mapping.
- New Managed Property
- Name: ebbbKeywords
- Type: Text
- Check Queryable
- Check Retrievable (optional, good for debugging)
- Check Allow multiple values
- Add a Mapping
- Select ows_ebbbKeywordsMatch
- OK
- OK
- SSA Admin > Content Sources > Local SharePoint sites > Full Crawl (or Content Source pointing to your site)
- 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
- Create Display Template
- Search Center > Site Settings > Master pages and page layouts > Display Templates > Search > Item_BestBets.html > Download a Copy > Save as Item_EvenBetterBestBets.html.
- Edit Item_EvenBetterBestBets.html
- <title>Even Better Best Bets</title>
- <mso:ManagedPropertyMapping msdt:dt="string">'bbTitleOWSTEXT':'bbTitleOWSTEXT','bbURLOWSTEXT':'bbURLOWSTEXT'</mso:ManagedPropertyMapping>
- Save
- Display Templates > File Tab > Upload Document
- Select file
- OK
- Save
- Create Result Type
- Search Center > Site Settings > Site Collection Administration > Search Result Types > New Result Type
- Name: Even Better Best Bets
- Show more conditions
- Which custom properties should match: Content Type
- (Value): EBBBList
- What should these results look like: Even Better Best Bet Item
- Check Optimize for frequent use
- Save
- Search Center > Site Settings > Site Collection Administration > Search Result Types > New Result Type
- Create Result Source
- Search Center > Site Settings > Site Collection Administration > Search Result Sources > New Result Source
- Name: Even Better Best Bets
- Query Transform: ebbbKeywords="{searchTerms}" spcontenttype=ebbblist
- Save
- Search Center > Site Settings > Site Collection Administration > Search Result Sources > New Result Source
- Create Query Rule
- Search Center > Site Settings > Site Collection Administration > Search Query Rules
- Select "Local SharePoint Results" > New Query Rule
- Rule Name: Even Better Best Bets
- Remove Condition
- Add Result Block
- Title: Best Bets for "{subject Terms}"
- Search this Source: Even Better Best Bets
- Items: 5
- Click Settings
- 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).
- Query Text: {searchTerms} -spcontenttype:ebbblist -ListURL:"Even Better Best Bets List"
- OK
- Save
- Select "Local SharePoint Results" > New Query Rule
- Search Center > Site Settings > Site Collection Administration > Search Query Rules
- Test Best Bets from Search Box
Comments
Anonymous
February 01, 2016
Hi Eric! Thank you for your interesting post. I've tried to set up hte solution and I've almost succeded, but have one challenge which I hope you can help me with. In my source list I have entries containing one word or multiple words - for example "sourcelist" and "source list". The problem is that only queries matching the entries with muktiple words triggers the best bet query rule - not single word entries. So "source list" works but "sourcelist" doesn't. Any suggestions?Anonymous
February 02, 2016
Sorry. Nothing specific jumps to mind. The scenario you describe works for me. I know that doesn't help you. :( I'd review the steps and make sure your lists are indexed correctly and your data is formatted correctly, You can use the SharePoint 2013 Search Query Tool to easily see the custom Managed Property data. Your query will look something like 'ebbbKeywords="<keywords>" spcontenttype:ebbbList'. Make sure Query Rules are turned OFF for your tests or you wont see results. You should see your multi-value terms delimited by a semi-colon in the results.Anonymous
February 08, 2016
Thank you for answer. I've tried the Search Query Tool which confirms my observations. Furthermore I've found out that 'ebbbKeywords:"sourcelist"' works (":" instead of "=") so the single word entry is indexed and queryable but it doesn't work as an exact match.Anonymous
February 25, 2016
Hi Peter, if ':' works, but '=' doesn't, you are probably using the wrong Column and/or List Content Types in your SP lists. The point of the exercise above it to be able to use the '=' or exact match operator because the ':' or contains operator, while it will work, leads to ambiguity in certain scenarios. Other content types will add metadata (e.g. taxonomical data) to the column value, so only ':' will work.Anonymous
February 06, 2017
Hi Eric,We've been using this solution for about 6 months now and it's worked really well. Ideally we'd like to expand it so that it could cover queries starting and ending with other phrases. For instance, our defined phrase is "harassment policy" and we'd like that to also match English discrimination & harassment policy. Is there any way to do that? In other words, we'd like to still cover our multi-word trigger terms like this solution allows us to do, but also accept if the user has appended other words to the query.Thanks!- Anonymous
February 27, 2017
Hi Bryn, I believe you could, but please thoroughly test. I haven't tested this out.First, you need to do a "contains" match on the key words list, but this reintroduces the problem that the solution is trying to solve (see the "United”, “United States” and “Manchester United" example above). The original Better Best Bet addresses your scenario. So, I would create a second list of terms that you know are unique and/or are phrases and repeat the process defined in the original solution or what is stated above for the second list, except for step 3.a.ii under the "From the Search Center Site" section. In that step, change the operator from an equals (=) to a colon (:).
- Anonymous