Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Overriding Confluence default searching strategy.

Sławomir Turlej
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.
August 8, 2011

Is it possible to override Confluence default searching strategy ?? For example I need to sort results by last modified date descending and by a custom page attribute "priority" descending. Priority ranges from 1 - 5.

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Daniel
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 11, 2011

Currently you can not sort search results using the sitesearch.action. However if you are really keen you could write your own plugin that allows you to sort. It would be a lot of work, as you would have to a bit of query parsing yourself. What it boils down to is you'd have to change the action that the search field goes to. In your new plugin action you would have to get your fields out, at the very minimum you'd need the query string, sort order, page size and page number. You would then pass that into the SearchQueryParameters. There are a few implementations of SORT that you can use, there is a TITLE sort for example. This would then be passed over to the PredefinedSearchBuilder which turns it into a query representation. This is then passed to the SearchManager which performs the actual searching and sorting. From there you'd have to pick up the results and pass it to your own velocity template for rendering as you want.

Bear in mind that sorting in the table would have to issue a new search as you would otherwise just sort a small subset of the corpus that matches the query. Like I said a lot of work, but doable. Upgrading to a new major version of Confluence may be hard if you are using a plugin like this, but with planning and testing it is doable.

Sławomir Turlej
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.
August 11, 2011

This approach is a way to go. I already implemented necessary functionality and it works fine. I just need to write renderers for other content that page so they display in a table.

4 votes
Daniel
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 10, 2011

There are two things you can do to impact search results. One is to write an extractor that adds a field boost for relevant fields. The other is to write a plugin that implements the BoostingStrategy which will give you control over how documents are boosted (at query time).

A very basic plugin could look like this

public class Booster implements BoostingStrategy
{
public float boost(IndexReader indexReader, int i, float v) throws IOException
{
return 1;
}

public float boost(IndexReader indexReader, SearchQueryParameters searchQueryParameters, int i, float v) throws IOException
{
return 1;
}
}

and the atlassian-plugin.xml would look like

<lucene-boosting-strategy name="pluggablestrategy" class="com.atlassian.test.Booster" key="my-booster">

More docs over on Confluence.atlassian.com http://confluence.atlassian.com/display/CONFDEV/Lucene+Boosting+Strategy+Module

There are of course also plugins that may suit your needs, such as the Confluence Awesome Search https://plugins.atlassian.com/plugin/details/32021

As always make sure you try your solution on a staging instance first. Preferably one that has a similar amount of content so you can catch performance issues before they hit your users.

0 votes
Sławomir Turlej
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.
August 10, 2011

Thanks, but that is not enough. I need to display search results in a sortable table (clicking on columns sorts the table). I have already managed to style search results such that they appear in a table (columns: title, creation date, ranking, location) by using Conveyor plugin and modifying search.vmd and search-results.vmd. Now I plan to add necessary functionality to SearchSiteAction. Baiscly, I need to sort search results by a title, creation date, ranking (my own field) such that it overrides any scoring strategy.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2011

I'd love to do this, as the "weighting" in Confluence is functionally useless for most of my clients - we need "authoritative" pages, and the ability to change the weights to something sensible rather than the social waffle that's the default.

The "rating" macro might help you a bit, although it doesn't fix the core searching pains.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events