Excude Sandbox results from Search

Hi there,

I would like the contents of the Sandbox to be excluded from search results (Solr), both for the quickSearch and the main search.

How can I achieve this? I don’t want to hide or blacklist the Sandbox.

I have read here that I can use

fq=-space_exact:Sandbox

for the quickSearch, but I am not sure how to use it for the main search results since I cannot see how to incorporate that into Main.SolrSearchConfig

Thank in advance for your help.

fq stands for “filter query”. So look for this

'filterQuery': [],

in Main.SolrSearchConfig, and replace it with:

'filterQuery': [
  '-space_exact:Sandbox'
],

Many thanks for your response, but it doesn’t seem to work for me with the Sandbox.

So if I modify Main.SolrSearchConfig to include

   'filterQuery': [
       '-space_exact:XWiki'
   ]

then I can see that results from the XWiki space (such as user’s profiles) are excluded.
However, this does not work for the Sandbox. How is the Sandbox space different from, say, the XWiki space in this regard?

This works fine for me:

'filterQuery': [
    '-space_exact:Sandbox',
    'hidden:false'
],

I did a search for “test” without it and I got 4 results from Sandbox. I did the same search with it and I got no results.

Note that the 'hidden:false' is needed because if you specify the filter query in SolrSearchConfig then you are overwriting the default filter query, which has 'hidden:false'. So you want to keep it.

Many thanks mflorea

I have now understood that -space_exact:Sandbox excludes results from the Sandbox page only, and not the pages underneath Sandbox.

In order to achieve what I want I need to add an asterisk at the end of Sandbox. As such, my Main.SolrSearchConfig includes:

'filterQuery': [
    '-space_exact:Sandbox*',
    'hidden:false'
],

and my Search Suggest queries look like:

fq=+type:DOCUMENT -space_exact:Sandbox*
qf=title^2 name

Search Suggest in admin/XWiki/XWikiPreferences?editor=globaladmin&section=searchSuggest has following query.

q=*__INPUT__*
fq=+type:DOCUMENT -space_exact:XWiki*
qf=space^5 name

It’s not excluding the XWiki-Space and it’s children.
Any idea?

Regards, Simpel