Pnp-modern-search: Do we have a way to exclude the contents of Site Assets and Form Templates libraries from the search results ?

Created on 20 May 2020  路  5Comments  路  Source: microsoft-search/pnp-modern-search

I have configured the Search Results web-part to return the results from the hub site and its connected sites by using following Query Template configuration.

{searchTerms} DepartmentId:{{PageContext.hubSiteId}}

Do we have a way to exclude the contents of Site Assets and Form Templates libraries from the above search results ?

All 5 comments

I think you and I are working on the same thing ... Replicating the hub search.

I noticed today that the out of the box hub search doesn't exclude the Site Assets. What I did for this library in my environment was remove it all together from search. From the Site Assets Library settings, go to advanced settings and turn off index for search there. That removed it for me.

As for Forms Template library, are you just talking about another library that holds your templates or are you talking about something else. If it just a library you don't want to show, you could do that same as Site Assets and exclude it.

Hope that helps.

Thanks for the suggestion @malcom1120 .

This is a manual workaround which i also thought of. But, this approach requires a regular maintenance effort of removing these libraries from the search index whenever a new site is attached to this HUB.

I am not an expert in this area but was expecting some generic solution. May be to somehow modify the Query Template to exclude these libraries or even some change in the search results layout template.

I have not been able to find one. The contentclass is the standard DocumentLibrary type. I can't seem to get a wildcard pattern that would work based on path or anything. This was the only way I have been reliably able to get it out of search.

Thanks again @malcom1120 . For now i will use your suggestion. I will also try to jump back to this once i get some free time.

There is no good way unfortunately outside of setting the libraries not to be indexed. Which is a solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stevebeauge picture stevebeauge  路  5Comments

RedGlow picture RedGlow  路  5Comments

MarcoSimon picture MarcoSimon  路  5Comments

vreezy picture vreezy  路  3Comments

PrabhuChandar picture PrabhuChandar  路  3Comments