0

Consider I have a folder in a SharePoint Library within a Sub site DM. The folder's name is: TEST CLIENT D'ORO

This is my search query:

{searchboxquery} Path:"https://rooturl.sharepoint.com/sites/DM/" ContentTypeId:0x0120D520* ContentTypeId:0x0101* ContentTypeId:0x0120*

Search Input: TEST CLIENT D'ORO, returns no results.

Search Input: TEST CLIENT D''ORO, returns results but not the folder.

Search input: TEST CLIENT, returns the expected results, including the folder.

The Folder only has a Title property. In the second scenario, the returned documents consist of a field ClientName with value TEST CLIENT D'ORO, which could explain why the search returned results. But how does it explain that it did not return the folder result with the same query? How can I search with the exact title (including escape characters if required) and return the expected results?

The Expected result: every folder and document whose title (or any other field) contains TEST CLIENT D'ORO within subsite DM in SharePoint online with url: rooturl.

1 Answer 1

0

I used the OOB refiners etc. This is my query -

{searchboxquery} (contentclass:STS_ListItem OR IsDocument:True) Path:{Site.URL}

Now, for the same set of inputs that you have, the search works properly -

Search Input: <code>TEST CLIENT D'ORO</code>

Update

Please refer to Query variables in SharePoint Server 2013.

Please refer to KQL reference in order to get a better idea at constructing queries.

Please refer to Working with Result Sources in order to understand how result sources work.

Update #2

Use the following query with the result scope -

{searchboxquery} (contentclass:STS_ListItem OR IsDocument:True)

Restricting Search results to a subsite only -

Site > Site settings > Search > Result Sources

enter image description here

Add a new Result Source . In Query Transform section modify the query to contain the following (i.e. your subsite url) -

enter image description here Create the Result source.

Now go back to the Search Results webpart. Make sure you select the result source to be the one you just created -

enter image description here

And then voila! the search results are only sourced the target subsite -

enter image description here

7
  • Thanks a lot for taking the time to recreate the problem. I tried your query and the result is identical to my query. However, when I am testing in the Test section of the Build your query panel in SharePoint online, I am seeing that the query is being changed a bit: (contentclass:STS_ListItem OR IsDocument:True) Path:"rooturl.sharepoint.com/sites/DM" -ContentClass=urn:content-class:SPSPeople Jul 13, 2017 at 10:02
  • Path:"abc.sharepoint.com" doesnt seem to work for me. are you manually building the query or using the query builder? Jul 13, 2017 at 10:21
  • ABC would be the name of the SharePoint. The extension of /sites/DM refers to the sub site called DM. When trying Site.URL, it does not work for me. Besides, I need to specify that this search needs to just work in the subsite and not the root collection. I am building the query in the Query text box in the Basics section of the Build your query feature. Don't forget that I am using SharePoint Online (if you are using On-Premise) Jul 13, 2017 at 10:31
  • Updated the answer as per your requirement. Please refer :). Also can you update the question with your complete set of requrirements from the search query. Jul 13, 2017 at 12:44
  • I have edited my question. I have also tried your update 2. The only thing it changes in my opinion is that it used the result source instead of the path that I was previously specifying within the query text. I am still not getting the expected results. I think it is somehow a problem with the quotes. Jul 13, 2017 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.