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.
Community moderators have prevented the ability to post new answers.
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.