2

So I have an SPO tenant I've set up with a few custom Search Verticals. Both of them are based on a specific content type.

Both these CTs are created in the root tenant site collection and used within a single document library within a /data subsite off the root site.

The first one is for Operational Document, which has a Site Collection CTID of 0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC202 and a CTID at the library level of 0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC20200DB00238345FE274AADE4658112D448D9.

The second is for Policy Document, which has a Site Collection CTID of 0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC203 and a CTID at the library level of 0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC203002D717125757D40459022779628937E9D.

Within the /search site collection I created two new pages, opdocresults.aspx and poldocresults.aspx as standard Search result pages and linked them to the relevant search boxes. All well and good so far.

Each of these pages has the Search Results WP configured with a query like {SearchBoxQuery} ContentTypeId:0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC20200DB00238345FE274AADE4658112D448D9, using the document library CTID (as using the site collection level one returned nothing, or when adding a * on the end returned more than I wanted).

This works fine in that it does return the documents I'm looking for, however, the problem is if you click onto the results page (from the options under the search box on any results page), even without a query specified, it will return all documents matching the given CTID.

Is this normal, or is there a way to set the query so it doesn't return anything until an actual search query has been issued?

2

Change your query so it does not return results if the Search Term is blank by wrapping it in {? }. I usually do this to the Result Source and then reference the Result Source in my Search Result web part. Either way I believe your query would be:

{?{SearchBoxQuery} ContentTypeId:0x01010400CABA81C4B7DC574FAC7ED817BD7A7AC20200DB00238345FE274AADE4658112D448D9}

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.