Lucene Boosting Strategy Module
Confluence 3.0 and later
Lucene Boosting Strategy plugins allow you to configure the scoring mechanism used by Lucene to order search results in Confluence.Each time a document is found via search, it is passed through the set of boosting strategies to determine its score for ranking in the search results. By writing your own boosting strategy you can customise the order of search results found by Confluence.
Lucene Boosting Strategy Plugins
Here is an example
atlassian-plugin.xml file containing a single search extractor:
- the class attribute defines the class that will be called to boost search result scores. This class must implement com.atlassian.confluence.search.v2.lucene.boosting.BoostingStrategy
The BoostingStrategy Interface
All strategies must implement the following interface, BoostingStrategy:
An Example Boosting Strategy
The following boosting strategy is used in Confluence to boost search results by last-modified date. Some of the logic to do with date-handling has been removed to simplify the example.
Using Field Caches
Note that this example uses a Lucene FieldCache, which stores a copy of all the modification data for all index entries in memory. If you are implementing a BoostingStrategy yourself, you should also use a FieldCache (rather than reading the index entries from disk) and be aware of their behaviour:
- the first time you use a field cache, it requires iterating through every index entry to warm up the cache in a synchronised block
- field caches are cleared every time the search index is updated (normally every minute in Confluence), which requires another warm-up
- field caches keep a copy of each term in memory, usually requiring a large amount of memory.
Be sure to measure the increase in memory usage required after installing your plugin and how well your custom boosting strategy copes with a large amount of data in the index that is updated every minute.
Confluence itself has only two active field caches: one for the "modified" field in the main index (as shown above), and one for "word" in the Did-You-Mean index. When a new Searcher is created after each write to the index, Confluence manually warms up the "modified" field cache with the following call:
It might improve performance to warm up any field caches when your plugin is initialised. There's currently no way for a plugin to determine when IndexSearchers are refreshed, so there may be a relatively frequent performance hit if you are accessing a FieldCache which hasn't been warmed up.
- For more information about plugins in general, read Confluence Plugin Guide.
- To learn how to install and configure plugins (including macros), read Installing a Plugin.
- For an introduction to writing your own plugins, read Writing Confluence Plugins
- Boosting Strategy plugins are closely tied to the API of the Lucene Java library
- Extractor Modules are a related plugin module type for the Confluence search system.