Limit Confluence header search to the current space
Asked by Nick Sills:

Hi

We're trying to improve our customers experience when using our KB here:  

<https://knowledgebase.macrium.com/>

1. Unfortunately the search bar in the page header returns results across all Spaces, We need to limit the search to the current space only.

Also...

2. Searches match on whole words only. Is it possible to match on partial?

Thanks for your help


Answers:
author: Daniel Eads
body: Hey Nick,

For limiting search, I'd recommend adding a **Livesearch** macro to either your KB's homepage, or in the header for your space. The parameters of the macro let you restrict results to a particular space. [Documentation showing how to set it up is here](https://confluence.atlassian.com/doc/livesearch-macro-163415902.html).

As an example of this, I've gone to the **Space Settings** \> **Look and Feel** \> **Sidebar, header and footer** and added the following to the header section:

```
{livesearch:spaceKey=TEST|size=large|placeholder=Search the KB}
```

This gives me a livesearch at the top of every page in the space, limited to that space:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/59152i38A2BB398D95F9EC/image-size/large?v=v2&px=999 "image.png")

In terms of matching partial words, you'll need to use the wildcard character (the asterisk - \*). Users will have to include this in their search string (there's no out-of-the-box way to include it by default). Here's an example of the livesearch returning a partial match:

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/59153i0AFABCCB3FF18D06/image-dimensions/611x110?v=v2 "image.png")

Cheers,  
Daniel

comments: author: Daniel Eads
body: Additionally - you might find [this thread of interest, specifically John Corwith's answer](https://community.atlassian.com/t5/Confluence-questions/limiting-search-box-to-a-space-by-default/qaq-p/100755#M87761) where he suggests using the Custom CSS for the space to also just hide the global search bar:

```
#quick-search{
? ? display:none;
}????????????????? 
```


author: Nick Sills
body: Thanks for the replies but we want to directly change the function of the header bar search not remove it. or add a different one at the top of each page.

Adding a search using **Look and Feel** \> **Sidebar, header and footer**wastes vertical space on the page.

Removing the search from the header bar would be preferable as the sidebar has a space restricted search already,\***but**\* the CSS doesn't appear to work and, more importantly, removing the search would break the search on mobile as there's no sidebar there.

Is there any way to directly modify the existing search on the header bar?

Thanks


author: Nick Sills
body: I managed to hide the header bar search by adding the following to the Space CSS:

```
.aui-header .aui-quicksearch {
display: none;
}
```

This is OK when browsing on a PC because the there's a search on the side bar. However, on mobile the only search is in the hamburger menu. I thought that by hiding the search on the header that this would also hide the mobile search, but it didn't.

Unfortunately the mobile search is still across all spaces.

Is there any way to modify the CSS or/add change the search behavior for the mobile site? The mobile site menu bar is totally inappropriate.

Thanks for your help


Tags: confluence-server

server