Tuesday, September 29, 2020

Search and modern multilingual pages in SharePoint Online

image

The ability to create SharePoint pages in multiple languages was/is a popular feature for classic SharePoint publishing pages. If you work in an organization where your employees use multiple languages, for example English and Norwegian, creating side by side pages in native languages is beneficial both from a communication point of view and also helps to tailor the information related to countries/regions based on language.

Back in SharePoint 2013 the functionality was called variations. This time around it’s more aptly named the “multilingual feature”. You can read the feature announcement from June 2020 at the Microsoft Tech Community.

While variations were an option for sites using the classic SharePoint publishing feature, the ability to create multilingual pages is currently enabled by default for Communication sites only.

If you want to enable multilingual page support on a Team site you can do so by activating a hidden feature called SitePagePublishing using for example PnP PowerShell as a site owner.

Connect-PnPOnline https://contoso.sharepoint.com/sites/mysite
Enable-PnPFeature -Identity f39dad74-ea79-46ef-9ef7-fe2370754f6f

If you want to take advantage of the ability to author multilingual pages, head over to Create multilingual communication sites, pages, and news which describes in detail how to turn on the capability as well as how to author the pages.

Details needed for search

What happens behind the scenes when you create multilingual pages? For one, each language copy is stored in its separate folder. In my case English is the primary site language, and I opted to have Norwegian as a secondary language.

image

Two pages in the original language.

image

One of the pages is translated.

Secondly, to connect and keep track of the original vs. the translated pages there are some internal properties in SharePoint per item keeping track of this.

SharePoint Column

Search Managed Property

Description

_SPTranslatedLanguages

SPTranslatedLanguages

Source page stores a list of the language of all translated languages.
E.g. nb-no.

_SPTranslationLanguage

SPTranslationLanguage

Translated page stores the language of the page.

E.g.: nb-no

_SPTranslationSourceItemId

SPTranslationSourceItemId

Translates page stores a reference to the original page.

E.g: 1f50aa8b-d31e-415a-bc4a-4ced38f5cdc4

_SPIsTranslation

SPIsTranslation

The translated page stores the boolean value true to indicate it’s a translation and not the original. The original article has no value.

The desired behavior when searching is to return a page in the users’ display language if it exists. If a translation does not exist, fall back to the original language – which follows the default language of a site set at site creation.

The examples below explain the logic used by Microsoft Search, and you can replicate this yourself as well in custom solutions.

To return English pages returned the query would be:

(SPTranslationLanguage:en-us OR (NOT SPTranslatedLanguages:en-us AND NOT SPIsTranslation:true))

image
Both pages returned in the original language - English.

To return Norwegian pages the query would be:

(SPTranslationLanguage:nb-no OR (NOT SPTranslatedLanguages:nb-no AND NOT SPIsTranslation:true))

clip_image008
One translated page and one non-translated returned.

If you are using the PnP Modern Search web parts you can use the query variable {PageContext.currentUICultureName} to substitute the correct display language into the query.

Easy as pie :)

PS! For the KQL savvy, you can not replace the NOT operator with the (minus) operator for boolean values – for some weird reason that fails.

Cover photo by Mat Reding @ Unsplash

Monday, September 14, 2020

Microsoft Search vs. PnP Modern Search – a clash of titans!

man standing and walking going on boxing ring surrounded with people

Sorry for the clickbait title. I have been meaning to write about how I think about the out-of-the-box Microsoft Search vs. the PnP Modern Search web parts for a while, so here goes.

Disclaimer: I have been working with search for 20 years, enterprise search for 15 years and SharePoint and search for almost just as long. The opinions stated are my own and they are based on my experience with search in FAST ESP, SharePoint and Office 365 over the years and are not influenced by my role as a program manager on Microsoft Search. No money or breaking of fingers were involved in writing this post :)

A little history

With SharePoint 2013, Microsoft shipped many ways to customize how search worked. Both from a technical and user experience perspective. The more important one being the ability to use arbitrary HTML, CSS, and JavaScript in custom display templates with the Search Result web part and the Content by Search web part (CSWP).

Fast forward to SharePoint Online and the release of modern SharePoint pages late 2016. Modern pages came with a new set of web parts and lacked the super-flexible CSWP. Modern pages did introduce the Highlighted Content web part (HCWP), positioned as “...the newer, simplified version of the Content Search web part.”

When customer transitioned from classic to modern a gap had been formed between the CSWP and the HCWP which needed filling. And this is where the awesome sharing in the SharePoint community comes in, put into a sharable system with Microsoft 365 Patterns and Practices (PnP).

The first version of the PnP Modern Search web parts (MSWP) were added as a SharePoint Framework sample by Franck Cornu back in October of 2017. My first contribution to the sample was made in January of 2018 to include additions needed for a customer project I had at the time.

Back then MSWP was one web part; the result web part which included an optional built-in refinement panel. The search box web part got introduced late February of 2018, with the vertical web part following later. My main reason for looking at the sample web part in the first place was the need of a roll-up web part for a project. The Highlighted Content web part (HCWP) lacked the needed templating required – and still does, and why bother develop something if it already exists? Much easier to add to a maintained code base compared to owning it completely on my own #lazyprogrammer.

image
Image by Zhang Kenny @ Unsplash.

And this is where I believe the PnP Modern Search web parts has its sweet spot – bridge the gap between the classic Content by Search web part and the new Highlighted Content web part. This was my opinion back in 2018, and it still is in 2020. I actually formed the opinion back in 2016. That is 4 years and counting.

Why? you might wonder.

The modern search page was soft launched as part of the SharePoint Home page with the May 4th event in 2016. An out-of-the-box non-configurable search page. The page itself did have a link at the bottom which took you to the classic enterprise search center, but it was indeed the start of mainstreaming the search experience. Microsoft removed the link in March this year without anyone really noticing, which leads to think it was the right thing to do :)

When SharePoint Home launched in 2016, I figured it’s time to stop creating classic display templates. I have a long history creating display templates and you can download some open source ones I started to create back in 2014 from github.com/spcsr. I call this out to emphasize I have indeed customizeded search in the past and thought it a good idea at the time. With the introduction of SharePoint Home the journey for Microsoft Search was started – one experience to work on across desktop and mobile – I changed my mind.

At Ignite 2017 the vision for Microsoft Search as you see it today was launched and the search experience from SharePoint Home made its way over to office.com. Last year, in 2019, Microsoft Search in Bing followed suit. From a slow start, Microsoft Search is hitting more and more client endpoints with the promise of a coherent search experience. Same search box everywhere, with predictable results – all driven by the same Microsoft Search backend. And this will continue to expand going forward.

Screenshots of app windows with Microsoft Search box in the header bar
https://docs.microsoft.com/en-us/microsoftsearch/overview-microsoft-search

Let us go back again four years to 2016. I don’t think myself as very good at predicting the future, but this time I got it right. My take was, if I cannot control which search box people search from with no options to customize the result page they get to, why spend a lot of time and money to create something custom?

Sure, I have the ability and skills needed to tune search both from a relevance and UX perspective to be awesome for a specific business. I ended up thinking it is not worth spending the time or money. I would rather use my consulting hours on other fun and valuable projects. Did I have to fight customers and argue my point? YES!! Many had invested in custom search solution for classic SharePoint and wanted the solution brought over as part of their cloud journey. For those who have been privy to these customers conversations they know the following to be a common Mikael statement:

“If you believe you are right and really really want to create a custom search experience, feel free to do so, but you have to get another consultant to do so. It could be my colleague, but it won’t be me.”

Hindsight I hope they see that I was right and that their money was better spent elsewhere.

If you add the personalized relevance introduced in 2017 based on the Microsoft Graph (then Office Graph) to the equation, it’s just not worth competing with it. Too hard. To me anyways.

Four years after the inception of the Microsoft Search search experience, Microsoft is finally adding capabilities customization capabilities to the search result page. You can add your own verticals, add your own refiners and limit what is returned per vertical (roadmap item 57054). Why did it take so long to get customization functionality...? Well, I do not have all the history as I joined the Microsoft Search team in June 2019. One key part is that Microsoft need to ensure the experience works in multiple clients, not only SharePoint. Therefore some of the classic SharePoint constructs (which were awesome when launched for SharePoint 2013, and still are today in terms of architecture) have to yield as Microsoft Search encompasses multiple clients and content. At the same time as classic search is being left behind I do believe we are also innovating with similar, better and certainly more cloud forward solutions from a technical perspective.

“If you’re so PRO Microsoft Search, why do you then work on, manage and promote PnP Modern Search?”

The answer is simple. Because I love to develop and I do believe PnP Modern Search has a good place in the eco-system for search driven apps, specific portal solutions, or for a more flexible roll-up web part in modern SharePoint pages. The portal/app scenario is available as a downloadable PnP provisioning template.

image

Did you see PnP Modern Search started to be mentioned on search roadmap slides in 2019? I might have had a finger to do here – and it is because Microsoft do see the value in providing full customization capabilities with search. For scenarios which really really really benefits from special technical and UX capabilities. SharePoint has always been a platform for those needing full flexibility, and it still is via the SharePoint Framework. For the majority of enterprise search needs I don’t believe this level of customization is needed.

Short term the PnP Modern Search web parts can potentially let someone create a better enterprise search center, and I know this happens, but it comes at the cost of educating your users to use a search box you control. An impossible task in my opinion, leading to a disconnected search experience for the end-user as users start their search journey from:

  • SharePoint Home
  • Office.com
  • Teams
  • Work, Excel, PowerPoint
  • Outlook
  • Windows 10
  • The browser address bar
  • Microsoft Search in Bing
  • Web application
  • Desktop application
  • Mobile applications
  • etc.

I honestly believe the out-of-the-box Microsoft Search experiences is the best way forward for most Microsoft 365 users out there, and Microsoft continues to strive to make it better. Not just for the majority of users, but also for the edge cases.

PS! I was about to lose faith in Microsoft Search back in January of 2019, but I’m back on track. Read my post The conspiracy is real! for more details.

If you believe me to be wrong and off my rocker I’m all ears for reasonable arguments to sway me over. Yes, I do acknowledge there are good reasons to control and customize enterprise search, but I find it hard to justify the investments vs. the outcome.

References:

Cover photo by Attentie Attentie @ Unsplash.