question

MeatsJessica-6655 avatar image
0 Votes"
MeatsJessica-6655 asked MeatsJessica-6655 commented

Refining by page language with PNP Search Web Parts

I'm putting together a custom search page using the PNP search web parts. I have my search results working fine, but it's for a tenant that's using the SPO multilingual pages and I want to refine by the language of the page.

There is a property SPTranslatedLanguage, which shows the language of any page that's a translation, but shows null for a page in the default language. So if I have the default language on the site as English with French and German as an available translation languages, then the translated pages will be tagged as French or German in this property, but the original English page that they're translations of will be tagged null.

This means if I map SPTranslatedLanguage to a refinable string property and add this in the search filters web part, I can refine by French or German, but there will never be an English option to refine by. Does anyone know how I could create a refinable property that would let me filter by the default language as well?



office-sharepoint-onlineoffice-sharepoint-server-development
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered MeatsJessica-6655 commented

Hi @MeatsJessica-6655 ,
We can refer to the following link to add refiners to your search results
https://docs.microsoft.com/en-us/sharepoint/search/how-to-add-refiners-to-your-search-results-page


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RaytheonXie-MSFT That doesn't help. I've already added a refiner. As I explained in my original question, I've mapped the property SPTranslatedLanguage to a refinable string property and I've used that as a refiner in the search page.

The problem is that the property only has a value for the translated pages - not the pages that are in the default language. I want to have a search refiner that shows the language for both the translated and the non-translated pages - that's where I'm getting stuck.

0 Votes 0 ·
MartinLaplante-0028 avatar image
0 Votes"
MartinLaplante-0028 answered

You can search on SPIsTranslation to return source pages on sites where Multilingual Page Publishing feature is on. That assumes that this source language is always English. If the source is not always English, then you can check for the combination of SPIsTranslation and SPTranslatedLanguages not including English.

If you want to find things by language regardless of whether the feature is on, then you can search by the managed property DetectedLanguage.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MeatsJessica-6655 avatar image
0 Votes"
MeatsJessica-6655 answered MartinLaplante-0028 commented

@MartinLaplante-0028
When I pull back SPIsTranslation, the debug mode on the search webpart is showing that property set to False for every result - even the ones that have a translated language. Even if I could retrieve this property correctly, it wouldn't be ideal because then I would have one refiner for "is it translated" as a yes or no and then another refiner for the translated language, instead of a single refiner for language.

I can't see DetectedLanguage as one of the optional properties to retrieve in the search results settings and when I try to map this onto a refinable string property, it doesn't show up in the search of crawled properties available to apply to a mapping. Am I missing something here?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You may have to republish the source and the translations in order for the hidden columns _SPIsTranslation, _SPTranslatedLanguages, _SPTranslationLanguage, and _SPTranslationSourceItemId to be properly crawled. Annoying.

DetectedLanguage is a managed property, not a crawled property, so you don't have to map it to a refinable string.

0 Votes 0 ·
MeatsJessica-6655 avatar image
0 Votes"
MeatsJessica-6655 answered MeatsJessica-6655 commented

DetectedLanguage is a managed property but it's not a refinable one, and I can't see it on the list of properties to retrieve in the search result web part.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I haven't done this myself, but for built in managed properties it is possible to edit them to be refinable, or to map them to a refinable property
https://docs.microsoft.com/en-us/sharepoint/manage-search-schema#refine-on-managed-properties

0 Votes 0 ·

That's the methodology I used to map SPTranslationLanguage - mapping it to a refinable string metadata property.

You can't change the refinable status of the built in properties. DetectedLanguage is not refinable and the refinable yes/no drop-down on the settings screen is greyed out.

In the settings of the RefinableString properties, I can add a mapping to a crawled property, but not another managed property. In the information for DetectedLanguage, it says it's mapped to the crawled property of ows_q_TEXT_TranslationLanguage so I've tried mapping that to one of the RefinableString properties, but that's coming back as null for every search result, regardless of whether or not it's translated.

0 Votes 0 ·