SharePoint PnP Search Results

Brass Contributor


Does anybody know how to use the Query Template and Refinement Filters part in PnP Search Results to exlude pages from the search?

I have a Knowledge Hub and created a search page. The Search Result webpart (before i do a search) shows everything in the Site - and i don't want that.

Idealy i will have it blank till a Search word is entered on the Search Box, but has not been able to do that, so i was thinking if maybe using the Refinement Filters i can exlud pages that are just templates.

I do have "FileType:equal("aspx") but i don't know how to say Title does not contain "Main"

i tried so many different things i found online and nothing seems to work.

Any clues?


2 Replies
Build your KQL query can be tricky at time, i've found creating a classic SharePoint page, adding the classic Search webparts and using the old UI to build your requirement can really help, then just copy the query built over into the new PnP Webparts.

you probably looking from something like the below to filter out main the title (using a - minus before it says you don't want to include any matches)

Thank you very much for answering my question!
I've never use this KQL before so don't even know how to separare the different filters (I tried , : Space and either the separator is wrong or the query)
I tried -Title:"*Main" Tile:-"*Main" Title:"-*Main" Same with FileName just in case but still nothing this is so frustrating. :(