Controlling what gets displayed in search results in confluence

Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2014

Does anyone know if there is a way to get to search results between the time the search engine retrieves its results and the time it gets displayed on the search results page in confluence?

The reason being is that I would like to exclude certain pages from appearing when a user does a search. All the pages I want to exclude have a title that starts with a underscore (ex: _page title). My thinking was that instead of messing around with lucene having it ignore pages that start with a underscore, I can cut it off before it displays the results in the confluence search results page.

In simple terms, I imagine adding some if statement where it checks the title of the page and if it includes a underscore, then it skips it, if not then it displays it on the search results page. I imagine this would be done in the search results page template or some place where lucene hands the search results off to confluence.

Does anyone know if what I am thinking is even remotely possible or if you know of a better way to handle my situation?

Thanks

2 answers

1 accepted

1 vote
Answer accepted
Adrian Moerchen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2014

You may do something like this:

  • Write a ServletFilter, which listens to the search call (api/searchv3 or something similar)
  • Extend the send "query" with something like "AND NOT title:_*"

https://confluence.atlassian.com/display/DOC/Confluence+Search+Syntax#ConfluenceSearchSyntax-NOTsearch

Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2014

Thanks. You post made me realize that its better to add "AND NOT title:_*" instead of just "-title:_" in the event the user is also adding some conditional to their search string. I am going to try doing it in javascript first and seeing how well that works before trying to create a servletfilter. Thanks

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2014

I believe the "-" does an implied AND NOT, but exlicitly stating it is ok too ... might look nicer for your users.

1 vote
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2014

Do you want people to be able to see these pages at all? If not then if you apply a viewing restriction to the page(s) it will not show up in search results.

Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2014

These pages are includes that appear in other pages. We essentailly created a library of include pages that get brought into other pages but when people search for something that appears in those include pages, they appear first. We want the actual page that its being included in to appear first. There is also no need for people to see these include pages so thats why we want to just hide them from search results altogether.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2014

Ah! Well, I've got no easy options for you then ... except maybe train your users to append "-title:_" to their search string ... or find a way to auto add it.

Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2014

I was hoping there was a way to do this in the page template for the search results page. Thought it would be possible to intercept the results before they get displayed on the page.

The one solution you mentioned may also work. I assume it would need to be done with javascript to append "-title:_*" to the end of search strings before it gets submitted to the engine.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2014

I think your options would be to use JavaScript to add it prior to form submission or to create a plugin that would do this. Either way you will need to do some development to get what you want ... I think.

Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 26, 2014

I was thinking the javascript route may be easier to do then having to create a plugin that will append that to search strings.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events