How to search for *partial* titles using the Confluence Search v2 API?

I’m still meeting an issue related to How to search for pages by title using the Search v2 API? . I can search using a page’s full title, but I can’t search by a portion of this title, so I can’t use that for autocomplete.

Example – Using TextFieldQuery returns several exact matches:

            SearchQuery searchV2Query = new TextFieldQuery("title", "Gatineau Municipal Election");
            SearchFilter securityFilter = SiteSearchPermissionsSearchFilter.getInstance();
            ContentSearch search = new ContentSearch(searchV2Query, new RelevanceSort(), securityFilter, 0, 20);

            SearchResults results = searchManager.search(search);
```
But `TextFieldPrefixQuery` returns no matches, whether with "Gatineau Municipal Election", "Gatineau", "Gat", "Gat*", etc:
        SearchQuery searchV2Query = new TextFieldPrefixQuery("title", "Some title");
        SearchFilter securityFilter = SiteSearchPermissionsSearchFilter.getInstance();
        ContentSearch search = new ContentSearch(searchV2Query, new RelevanceSort(), securityFilter, 0, 20);

        SearchResults results = searchManager.search(search);
Interestingly enough, the first returns results for "Gatineau", "Gatin*", "Municipal", "Municip*", but no results for "atineau", "*atineau" or "*atineau*".

Is that a bug and how can I retrieve all pages with a title that contains "a substring"?

Confluence’s search queries are mostly wrappers for lucene. Can you use wildcard query instead? The prefix query does exacttly what it sais: app will search for app*
I woukd suggest google for lucene based solution which should be transfer to confluence.

Please forgive my mobile typung. I would strongly suggest to read Lucene Query Syntax - Lucene Tutorial.com
You also set leading wildcard with
QueryParser queryParser = new QueryParser(…);
queryParser.setAllowLeadingWildcard(true);
Query q = queryParser.parse(“*ice”);
But performance is impacted and have to figure out how to use it in confluennce:)