Getting error with LuceneQueryMapper in Confluence 8

Greetings everyone,

I’ve been working on an old project that uses many deprecated APIs. While working on the compatibility with Confluence 8, we hit an error java.lang.NoClassDefFoundError: com/atlassian/confluence/search/v2/lucene/LuceneQueryMapper during the app installation. I realized that direct access to Lucene has already been sealed and is not accessible from Confluence 8 onwards.

I’ve browsed through the community and found out that the replacement of LuceneQueryMapper is to use TermQuery directly. But I’m having a hard time trying to figure out several things:

  1. What is Lucene Query Mapper? It is a module defined in atlassian-plugin.xml:
    <lucene-query-mapper key="macroName" class="com.adaptavist.confluence.theme.engine.macros.upgradetasks.search.MacroNameQueryMapper" handles="macroName"/> in the Java doc it says that this API converts SearchQuery to LuceneQuery. But I’m still unclear with the explanation and I can’t find anything on the official documentation.

  2. How to replace Lucene Query Mapper with TermQuery, I can’t find any example.

Any advice would be appreciated!