SOLVED

Configuring PnP Modern Search v4 to Display Search Results Based on Partial Keywords

Copper Contributor

Hi everyone,

I've created a search engine using PnP Modern Search v4, utilizing a SharePoint List that I personally set up with the following query template:

{searchTerms} Path:https://{my-o365}.sharepoint.com/sites/{my-site/my-subsite}/Lists/{list-name} contentclass:sts_listitem

arine1901_0-1702257353347.png

 

Currently, I'm facing an issue where I need to type the full word ("Surabaya") in the City column to get the desired search results. However, I want to configure the search terms so that typing a keyword like "Sura" will display the row with the value "Surabaya" in the City column.
arine1901_1-1702258043033.png

---

arine1901_2-1702258067096.png

Can anyone guide me on how to achieve this configuration? I appreciate any assistance in optimizing the search functionality to provide more intuitive results based on partial keywords.

Thank you!

3 Replies
best response confirmed by arine1901 (Copper Contributor)
Solution

Hello @arine1901

 

you can use * as a wildcard after the term do you search. As example:

No results

DavidMehr_0-1702622157729.png

 

And now with *:

DavidMehr_1-1702622183599.png

 

You can find more about search syntax:

https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-synt...

 

Please attention: KQL queries don't support prefix matching with the wildcard * as prefix.

 

Best, Dave

It works!
Thank you for the solution!

@arine1901 To enhance partial keyword search in your PnP Modern Search v4 setup, modify the query template by incorporating fuzzy search operators. These operators enable searching for words similar to the specified term, even if they're not an exact match.

 

{queryTerms:contains(["*Sura*", *Surabaya*]) Path:https://{my-o365}.sharepoint.com/sites/{my-site/my-subsite}/Lists/{list-name} contentclass:sts_listitem}


{queryTerms:contains(["*Sura*", *Surabaya*]) Specifies the search terms using the contains operator. In this case, it looks for words containing the substring "Sura" or the exact term "Surabaya."

 

Path:https://{my-o365}.sharepoint.com/sites/{my-site/my-subsite}/Lists/{list-name} contentclass:sts_listitem Specifies the source of search results, targeting the SharePoint List named "list-name" in the "my-subsite" subsite of "my-site" on the "my-o365" O365 tenant.

1 best response

Accepted Solutions
best response confirmed by arine1901 (Copper Contributor)
Solution

Hello @arine1901

 

you can use * as a wildcard after the term do you search. As example:

No results

DavidMehr_0-1702622157729.png

 

And now with *:

DavidMehr_1-1702622183599.png

 

You can find more about search syntax:

https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-synt...

 

Please attention: KQL queries don't support prefix matching with the wildcard * as prefix.

 

Best, Dave

View solution in original post