Wrong Sharepoint Search Results for Search Queries with 2 (or more) Words

S. Kunze 5 Reputation points
2025-05-30T09:28:31.7533333+00:00

Dear experts,

I encountered the following issue with the Sharepoint Search functionality used by means of PnP Modern Search: When entering one word as search term, the results are fine. However with two (or more) words, the results are wrong and behave in an erroneous way.

In particular I observed the following behavior: A search item is returned when searched for either <word 1> or <word 2>. However, when searching for <word 1> + <word 2> there is no result. Sometimes, it is even more strange and the order of the search words determines if there is found a result or not. For example search term <word 1> <word 2> returns a result but <word2> <word 1> does not.

I reproduced this wrong behavior by means of a Sharepoint page with only one managed property that is used for search and the following text, that contains sample words of type "WuselX" that are nowhere found. If you want to reproduce the error, you may use this text and search for "Wusel1" and "Wusel2" which will produce a search result, while "Wusel1 Wusel2" will not.

This is the text:

This description is used to test the search functionality running only on the description. Search for one or more of the following words: Wusel1 and Wusel2 Wusel3 Wusel4 Wusel5 now there are filler words to extend the distance Wusel6 Wusel7 and a word in paranthesis (Wusel8). (This sentence Wusel9 is in parenthesis.) Wusel10

And here the results:

Screenshot 2025-05-30 at 11.22.59

Screenshot 2025-05-30 at 11.23.18

Screenshot 2025-05-30 at 11.23.45

Does anybody has an explanation for this behavior and an idea how to fix it. Obviously, if I search for several words, the Search should return all objects that contain all of the search words.

Thank you in advance!

Microsoft 365 and Office SharePoint Server Development
{count} votes

1 answer

Sort by: Most helpful
  1. Kasper Larsen 0 Reputation points MVP
    2025-06-18T11:49:49.4+00:00

    Oh, but you do have access to the developer tools, as it is in your browser. Hit F12 and you will see it.

    I replace your RefinableString121 with RefinableString00 ( mapped to title ) and it works just fine here, this is the in the response when I search for "in details" :

    "Key": "QueryModification",

                    "Value": "( ( RefinableString00: in details ) ) Path:\"https://contoso.sharepoint.com/sites/PnPModernSearchHQ\"/SitePages -ContentClass=urn:content-class:SPSPeople",
    
                    "ValueType": "Edm.String"
    

    So it sounds the error is in the data. In order to inspect the data returned by search, I can recommend the browser extension SP Editor


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.