8

I have a site with two webparts (search input field and search results). On each pageload it's searching for an empty string and returns all results, similar to "*".

Querytext: {SearchBoxQuery}( IsDocument:"True" OR contentclass:"STS_ListItem_GenericList")

Is there a way to show the results not until the user presses enter or the search button?

Thanks in advance!

  • Why don't you specify If Condition if not null? – SharePointMan Apr 8 '14 at 11:54
  • Where can i do this, what's the Syntax for my querytext? – mbauer Apr 8 '14 at 13:24
  • Using the "?" before the {searchTerms} seems to be breaking an exact match search, for example, if I used double quotes and two search terms as "cloud computing", zero results are displayed. Anyone see this behavior? – JustMy2Cents Jun 2 '17 at 18:16
18

Try to wrap it in {? }

{?{searchTerms} (contentclass:STS_ListItem OR IsDocument:True)}
  • 1
    This worked for me as well. Is the question mark in the documentation at all? I can't seem to find it. – Omar Stewey Oct 4 '14 at 3:25
  • Nope - you Can see it sometimes in a preconfigured webpart. You can read more about it in Mikael's awesome series: melcher.it/s/2R – Max Melcher Oct 4 '14 at 6:56
  • 2
    Thanks Matt! Even 2 years later, you are still helping people! – user53667 Apr 26 '16 at 13:59
  • Haha - thanks for that one mate. And can call me Matt if you want :) – Max Melcher Apr 26 '16 at 21:17
  • I'm trying to do something similar with queries...but ran into a glitch... if you try to use this syntax in the Result Sources queries... it looks like things break... I think because by default, when you build the query there, it slaps on the -ContentClass=urn:content-class:SPSPeople to the end of the query string, no matter how you type things in... have you seen that before...or know a fix? – Carp Jun 15 '16 at 15:29
0

If you set the Query Transform like, it will not load the results on page load.

{?{searchTerms} Path:https://my.sharepoint.com/sitename/Shared%20Documents}
  • Same for me! any idea how to get this working with the "?" – Murtuza Husain Jan 9 at 15:37

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.