Optimize SharePoint Search Results using Auto Tagged Content

Solution-Featured

Sometime ago, I wrote an article explaining how to use Azure Text Analytics Service to Automatically Tag Documents stored in SharePoint document libraries. The expected outcome would be that most of your SharePoint documents would be “Tagged” with keywords extracted from the content of the corresponding documents.

But what next? How does it help? Let’s take a look at how can we benefit once we have most of the documents properly tagged.

Target State

Before we jump in to the benefits, let’s establish what we are trying to achieve here

  • Create an additional field, say Content Area(s), in the document libraries and associate that with a term set which will contain all the identified keywords for your organization
  • Use Azure Text Analytics Service to Identify the keywords extracted from the content of any document
  • Compare the keywords with the terms in the associated term set and find out matching terms and update those terms in the Content Ares(s) field for that document
  • Use the values of Content Area(s) field to boost the relevancy of such documents in search. i.e. when a search query matches the tagged keywords, those documents having same keywords should be marked as more relevant

How to go about it

First three points out of four, I already explained in my previous article how to use Azure Text Analytics Service to Automatically Tag Documents. But I would just add an alternative approach as well.

Tag Content

That article actually creates a console application which can iterate through your SharePoint documents and tag them. That would work best for all existing documents and in SharePoint on-premises environment, where you would have a server to run your console application.

Many customer have either already moved to SharePoint Online or in a process of doing so. If that’s the case, you could use the same code but using MS Flow and Azure Function this time.

Solution

  • A console application/MS Flow reads all the documents (docx and PDF) from all document libraries from a given site recursively (i.e. from all folders/sub folders) and calls an Azure function over HTTP call.
  • An Azure function Gets the information like Site URL, Document URL etc. and reads the textual content from SharePoint. It calls the Azure Text Analytics Service to find out keywords from that text and updates the document metadata.

You can also use a mix of both, console application to tag all the existing documents and MS Flow/Azure Function combo for all new documents afterwards.

Configure Search

Now that most of your SharePoint documents are tagged with relevant keywords, comes the core of this article. We have two ways in which we can configure search so that relevancy of tagged documents are improved.

Before we go into those, there is a common step which applies to both alternatives. We need to create a managed property in Search Service Application and map that to the crawled property of that Content Area(s) field.

  • Create a new Text type Managed Property, say “ContentAreas”
  • Map it to the Crawled Property “ows_ContentAreas”
  • Configure the managed property as Searchable, Queryable and Retrievable.
  • Also set Allow multiple values to true

Now that we have the managed property in place. Let’s look at the alternavites.

Influence the ranking of search results by using the search schema

For the newly created managed property, Click on the “Advanced Searchable Settings” button

Advanced Searchable Settings

and change the weightage group to “Context 1” and click OK.

Advanced Searchable Settings Context

What this tells SharePoint search engine is to boost the relative contribution weight ranking to 0.3610 from default 0.0194. This makes the values stored in this property equivalent to the title of the documents. You can take a look at this article for reference.

Once done, you need to reindex the content. In a SharePoint online environment, you need to do it for each document library separately once.

Now, try to search for any keyword which appears in any tagged document and if you compare that with non-tagged documents you could see tagged documents appear closer to top of the results.

The above solution applies to both SharePoint on-premises and online environments.

Influence the ranking of search results with query rules

The other alternative gives more control on the configurations, but at the time of writing this article, isn’t supported in SharePoint online modern search result pages. You can still use it with SharePoint Online classic search result pages.

The basic idea is simple, use the option “Change ranked results by changing the query” to boost the ranking if the incoming query contains any tagged keyword.

So, just a create a new query rule with context as “Local SharePoint Results” as shown below.

Advanced Query Rule

See, the magic happens in the Actions section, the query gets transformed to boost the ranking, if there is any match with the keyword.

[code]
{searchTerms} XRANK(cb=1){?ContentAreas:{searchTerms}}
[/code]

You can play with the value of “cb” to see the ranking in the output.

Best part of this solution is that you won’t have to reindex the content every time you make any changes here. Since, it simply works with queries and doesn’t change anything in the index itself.

Final Outcome

And at last what you might be waiting for, how to verify if all of these helped.

Well, I made a copy of a site from production to a test environment and ran our tagging application to get the documents tagged. Then I could simply perform SharePoint out of the box search with scope as Search this site and compare the results and whoa… see if improvement of ranking of tagged documents.

Search Keyword

Document name

Production(source) Position (not tagged)

Test Position (Tagged)

Business meetings

Skype for Business user guide

7

4

document collaboration

OFFICE 365 CHEAT SHEET

4

2

OneDrive

Create files and folders in OneDrive for Business

50

1

OneNote

OFFICE 365 CHEAT SHEET

33

13

Microsoft Teams

Share a Document Library from cloud storage in Teams

11

6

global service desk

Waffle Announcement dr4

21

5

Cloud

Save documents online

22

7

Note the difference in ranking is there because by default, SharePoint would give these keywords weightage same as any other words appearing in the content. With content tagging and search optimization, we just ensured that such important keywords get weightage same as document title.

Hope this helps.

Thanks,
Anupam

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *