0

I have ecoutered a strange behavior with search results web part. The scenario is, that we have blank page with some web parts on it. Part of the page is also search box web part and search result web part. They are correctly connected. I have configured everything needed to search only in certain library and everything is working fine, but when I refresh the page, search result web part is populated with items without any search attempt.

I configured the query to be: {searchboxquery} (STS_ListItem_DocumentLibrary) path:https://MySite IsDocument:1 FileType:doc* FileType:xl* FileType:ppt*FileType:one FileType:emlFileType:msg FileType:-od* FileType:pdf FileType:vd*FileType:vsd* FileType:vss* FileType:xps FileType:rtf FileType:xlt* FileType:pot* FileType:dot*

Is there a way to:

  1. Display the search result web part only when user try to search something OR
  2. Get rid of the irrelevat "results"?

We have SharePoint Enterprise 2013 SP1

Thank you for any advice.

EDIT: After exporting the web part I changed SendContentBeforeQuery property to false. It had no effect. I also found, that this property had issues and they patched it in cumulative update for March 2013. We have that update installed.

3

Try wrapping your entire query with {? your query }.

  • Thank you, but no change. I wrapped the entire query like {? searchboxquery (STS_ListItem).....FileType:doc*} and {? searchboxquery} {?(STS_ListItem).....FileType:doc*} but no luck... – MahonyCZ13 Feb 19 '15 at 13:40
  • Why not convert that query into a Result Source and then reference the result source? That's where I have used the {? .. } trick. – Matthew McDermott Feb 19 '15 at 18:56
  • Well i created result source based on your suggestion and tried every possible combination on how to wrap the query, but it did not return any results or it gave me every document on site. Still, main problem stands: the default view of search result web part displaying items without query. – MahonyCZ13 Feb 20 '15 at 7:56
  • Worked for me by just adding a question mark in front of the searchBoxQuery, like ?{searchBoxQuery} Path:somepath..., no need to wrap the entire query. – Dylan Cristy Oct 27 '17 at 17:52
3

I just wanted to add that you could always do it like this

Search only site collection and only doc or pdfs

{?{searchBoxQuery} (FileType=docx OR FileType=pdf) Path:{Site.URL}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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