FrancoisZhang commented on a change in pull request #489:
URL: https://github.com/apache/jackrabbit-oak/pull/489#discussion_r804189904
##########
File path:
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/ElasticRequestHandler.java
##########
@@ -779,41 +779,13 @@ private static QueryBuilder referenceConstraint(String
uuid) {
}
private static QueryBuilder fullTextQuery(String text, String fieldName,
PlanResult pr) {
- // default match query are executed in OR, we need to use AND instead
to avoid that
- // every document having at least one term in the `text` will match.
If there are multiple
- // contains clause they will go to different match queries and will be
executed in OR
- if (FieldNames.FULLTEXT.equals(fieldName) &&
!pr.indexingRule.getNodeScopeAnalyzedProps().isEmpty()) {
- MultiMatchQueryBuilder multiMatchQuery = multiMatchQuery(text)
- .operator(Operator.AND)
- .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS);
- pr.indexingRule.getNodeScopeAnalyzedProps().forEach(pd ->
multiMatchQuery.field(pd.name, pd.boost));
- // Add the query for actual fulltext field also. That query would
not be boosted
- // and could contain other parts like renditions, node name, etc
- return multiMatchQuery.field(fieldName);
- } else {
- //
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
- // simpleQueryStringQuery does not support leading wildcards
whereas it's supported by default in queryStringQuery
- // Not using queryStringQuery by default , since some functional
cases break.
- // simpleQueryStringQuery is less Strict, for instance searches
for terms starting with / work, whereas
- // with queryStringQuery, they throw an Exception (which
ultimately results in an empty result set in oak),
- // so using simpleQueryStringQuery by default would break certain
functional cases.
- // So only support this in case any term in the text String
actually starts with *
- // For example *hello or Hello *world
- String[] textTerms = text.split(" ");
- boolean allowLeadingWildCard = false;
- for(String textTerm : textTerms) {
- if (textTerm.startsWith("*")) {
- allowLeadingWildCard = true;
- break;
- }
- }
-
- if (allowLeadingWildCard) {
- return
queryStringQuery(text).field(fieldName).defaultOperator(Operator.AND);
- } else {
- return
simpleQueryStringQuery(text).analyzeWildcard(true).field(fieldName).defaultOperator(Operator.AND);
- }
+ LOG.debug("fullTextQuery for text: '{}', fieldName: '{}'", text,
fieldName);
+ QueryStringQueryBuilder queryStringQueryBuilder =
queryStringQuery(text).defaultOperator(Operator.AND)
+ .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS);
Review comment:
@fabriziofortino makes sense, I just fix that way and revert the test
change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]