Manual
-
Basics
-
Theme development guide
-
Template reference
- Page context
- Blog overview context
- Search context
- Error context
-
Placeholders
- Attachment
- Blog
- Comment
- Comments
- Find
- HtmlFragment
- I18n
- Image
- Include
- Label
- LabelList
- Language
- Languages
- Link
- Linkable
- Month
- Page
- PageProperties
- Pager
- PagerPage
- Pages
- Repository
- SearchRequest
- SearchResult
- SearchResults
- Space
- SpaceLogo
- StringEscapeUtils
- Theme
- Tree
- Url
- UrlEscaper
- User
- UserStatus
- Variant
- Variants
- Version
- Versions
- Viewport
- WebResources
- XsrfToken
- Year
- Supported macros
- Theme guidelines
- Theme properties
-
Template recipes
- Templates
- Navigation
- Search and SEO
- Confluence/Viewport macros and features
- (External) files and media
- Integration with other Scroll Add-ons
-
Integration with third-party software
- Displaying Additional User Information from the User Profile Plugin
- General 3rd party add-on implementation
- Integrating Disqus Comments
- Making Gliffy macros resizable
- Making UI-Expand macro of RefinedToolkit work
- Displaying Viewport Content in an iframe
- Integrate Midoris Archiving Plugin
- Trigger EliteSofts Page View Macro through Scroll Viewport
- Content Management via Page properties
- Context-Sensitve Help
-
Administration
-
Reference
How to improve search results for multiple strings

Thomas Rough Last update: Oct 17, 2018
Problem
By default, Scroll Viewport uses the standard Confluence search functionality. Therefore, if you search with multiple strings, Confluence will do an OR-Search by default. For example, if you search for 'Scroll Viewport' the search will find results for 'Scroll' 'Viewport' and 'Scroll Viewport'. As a result, this search process might include some results that you are not looking for.
However, to perform an AND-Search in Confluence, you can simply wrap your string in double quotation marks, like this "Scroll Viewport". Using this process, means you will only get results which contain 'Scroll Viewport'.
This article will explain how you can setup AND-search in your Viewport without having to add double quotation marks to your search term(s). This article is using the Scroll Web Help Theme as a base.
What you need
- Some basic knowledge in JavaScript
- a Theme Editor
- a copy of the Scroll Web Help theme
Changing the search from OR-search to AND-search
- Open your Theme in the Theme Editor
- Navigate to assets > js > scroll-search.js
- Change the following on line 10:
var url = 'q="' + query + '"&s=*&max=5';
After the q=
and before the &s
we need to add double quotation marks. This will wrap the given query and the Confluence Search will perform an AND-Search.
Additionally, it is necessary to do the same for the quick-search on line 49 in the same file:
var url = $('form#search').attr('action') + '?q="' + query + '"&s=*&max=7';
Since these changes will affect the displayed search terms on your results page, we also need to remove the double quotation marks from the velocity template. To do this:
- Navigate to include > include-search.vm
- Implement the following change on line 30:
<h1 class="search-header">Search for <em>$searchRequest.queryString</em>
The placeholder $searchRequest.queryString
is wrapped in double quotation marks which needs to be removed.
Your Confluence search is now performing an AND-Search by default in your Viewport.