Domanda

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?

È stato utile?

Soluzione

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}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top