Wilcard in Phrase Queries Support

Description

As a user I expect wildcards to be used for terms in a phrase and build a positional query where each element satisfy the wildcard if present.
Wildcard in Phrase queries in a complex topic and its support must be carefully designed and implemented in both AFTS and Lucene query language.
e.g.
@cm\:name:"a b?g y*ow b?n?na

Currently it is unsupported in both the language, you find the various examples for the syntax in this list of tests (that must be changed when support is implemented):

org.alfresco.repo.search.impl.elasticsearch.query.BaseWildcardQueryIT

org.alfresco.repo.search.impl.elasticsearch.query.language.lucene.WildcardQueryIT
org.alfresco.repo.search.impl.elasticsearch.query.language.afts.WildcardQueryIT

In AFTS in some scenarios used to "appear working", but not because it was supported carefully.
Just because some text analysis coincidence brought separate token in the index and the same happened at query time using the Match Phrase query builder.
We must make sure that in AFTS , Elasticsearch is used to build span queries including inner wildcard queries (using the ideal QueryBuilder, potentially using Match Phrase queries)
This approach may be good enough but must be investigated to understand if it's fully compliant with our requirements.

We must investigate if it's possible to support it in Lucene(this may be a bit tricky because we need to build such span queries on our own in the LuceneQueryParser or bypass it and use the same Elasticsearh

This is an example of additional tricky scenario that should work (the wildcard is at the place of a token separator.

This must be fully investigated, support must be introduced, tests and documentation updated in correspondence with the full requirements listed in the tests

Reference:
https://solr.apache.org/guide/6_6/other-parsers.html#complex-phrase-query-parser

Acceptance Criteria

  • Support is introduced for both AFTS and Lucene query language

  • Tests that were there to remember the unsupported syntax must be revised, renamed and made appropriate for the feature now supported

Assignee

Unassigned

Reporter

Alessandro Benedetti