Term search that contains a special character

Hello,

with Confluence 7 we have a working App that uses Lucene QueryMapper directly:

public class IsTermQueryMapper implements LuceneQueryMapper<IsTermQuery> {

    @Override
    public Query convertToLuceneQuery(IsTermQuery searchQuery) {
        return new ConstantScoreQuery(new TermFilter(
                new Term(TERM_KEY_FIELD, searchQuery.getTermKey())));
    }
}

Due to the access removal in Confluence 8, this class has been deleted, and, as the information that Atlassian states, it is done overriding the expand function in the IsTermQuery class:

@Override
    public SearchQuery expand() {
        return new ConstantScoreQuery(new TermQuery(TERM_KEY_FIELD, getTermKey()));
    }

Questions:

  • Do I need to add some sort of TermFilter? And if, how?
  • This is working as long as the Term Key has no special characters. When, for example, it contains a minus (-), the rest of the term is ignored, so a search for “term-key-field:term-key” gives the same results as “term-key-field:term”. I’ve tried escaping with double quotes, single quotes and a backslash, with no results.

Regards,
Ansgar

I’ll answer myself: I had to use StringFieldDescriptor instead TextFieldDescriptor. Funny thing is, this works for Confluence 8.5, and is already deprecated in 8.6. Also, the Extractor2 documentation has been updated (with errors) and works only for > 8.6.