Can I limit a search in the global search box to a certain space?
Asked by Gary Rosenstein:

In Confluence, is there any way to limit a search in the global search box to a specific space?

E.g., SPACEKEY: searchTerm

I am building a glossary space and I want people to be able to search for a term from anywhere in Confluence and have it come up prominently in the search results. So a search might look like this - GLOSSARY: widgit

This would be prefereable to making them navigate to the Glossary space and then perform their search.

Maybe there is an add-on that provides this functionality?

Thank you.


Answers:
author: Ellen Feaheny [AppFusions]
body: Gary -

Unless I am misunderstanding what you are asking, there is not an add-on BUT this is not a very hard plugin to adjust the global search bar to work this way, where it defaults to all spaces, but has perhaps a dropdown to select a space (i.e., glossary, etc.)..

Or - put the livesearch macro in a central page. Type:

```
{livesearch}
```

in the page. Save the page. Edit it, and double click on the macro to edit additional parameters including a space key if want to limit (All the parameters [are defined here](https://confluence.atlassian.com/display/DOC/Livesearch+Macro) - if you want to do direct using the "insert wiki markup" option.)

It this really bugs you or your users - we can create that "plugin" with UX modification as described in your Confluence system for you quickly. [info@appfusions.com](mailto:info@appfusions.com) Know that as a separate plugin, it will not affect your upgrades, but might require modification between upgrades.


author: Boris Berenberg
body: There isn't a great way to do this. What you can do is to configure the documentation theme to restrict search within the space the user is viewing. Take a look at: <https://confluence.atlassian.com/display/DOC/Using+the+Documentation+Theme#UsingtheDocumentationTheme-Searchingthespaceorthesite> For this to work in your scenario, the user would have to be within the GLOSSARY space to begin with. You could also put GLOSSARY into the page name, and then use that as part of the search to make it more accurate?

comments: author: Gary Rosenstein
body: Thank you Boris. I was hoping to streamline the glossary search so a user wouldn't have to navigate to the glossary space before performing their search. If they have to navigate to the space first, they can just use the existing space search box in the left nav, or i can put a space search box on each page in the glossary. Either way, this requires several clicks in the workflow to get to the term search:1) Click on Spaces2) Select Space Directory3) Filter for Glossary4) Click on Glossary5) Enter Search term in the left nav search box(of course, this may be short-cutted a little for savvy users who use favorite spaces or bookmarks - but we can't rely on that)The workflow I would like to see is this:1) Go to the global search box at the top any confluence page and enter GLOSSARY: yourSearchTerm- while maintaining the ability to perform global content searches by omitting 'GLOSSARY:' from the search query.It seems like the ability to use a SPACEKEY in the global search would be a useful feature.


author: Boris Berenberg
body: I totally agree with you and encourage you to file a suggestion for this at: <https://jira.atlassian.com/>


author: Davin Studer
body: If you look at the source for the form you will see a hidden input like this ...

```
&lt;input type="hidden" name="where" value=""&gt;
```

the value should be either conf_all or the space key you want to search. You could set it with this...

```
&lt;script type="text/javascript"&gt;	AJS.toInit(function(){		AJS.$('#quick-search input[name="where"]').val("conf_all");	});&lt;/script&gt;
```

comments: author: Gary Rosenstein
body: Thank you for the response Davin. The problem then becomes that ALL searches would be limited to the space defined (i.e., glossary). I want people to be able to perform global searches for content as normal, but restrict the search to the glossary space when they specifically want to search for a glossary term.


author: Davin Studer
body: Ok. If you set it to global search (conf_all) then you can put "stuff AND spacekey:???" in the search field and you should get the results only for that space.