[ https://issues.apache.org/jira/browse/OAK-2733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Mueller updated OAK-2733: -------------------------------- Fix Version/s: (was: 1.3.9) > Option to convert "like" queries to range queries > ------------------------------------------------- > > Key: OAK-2733 > URL: https://issues.apache.org/jira/browse/OAK-2733 > Project: Jackrabbit Oak > Issue Type: Improvement > Components: query > Reporter: Thomas Mueller > Assignee: Thomas Mueller > Labels: performance > > Queries with "like" conditions of the form "x like 'abc%'" are currently > always converted to range queries. With Apache Lucene, using "like" in some > cases is a bit faster (but not much, according to our tests). > Converting "like" to range queries should be disabled by default. > Potential patch: > {noformat} > --- src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java > (revision 1672070) > +++ src/main/java/org/apache/jackrabbit/oak/query/ast/ComparisonImpl.java > (working copy) > @@ -31,11 +31,21 @@ > import org.apache.jackrabbit.oak.query.fulltext.LikePattern; > import org.apache.jackrabbit.oak.query.index.FilterImpl; > import org.apache.jackrabbit.oak.spi.query.PropertyValues; > +import org.slf4j.Logger; > +import org.slf4j.LoggerFactory; > > /** > * A comparison operation (including "like"). > */ > public class ComparisonImpl extends ConstraintImpl { > + > + static final Logger LOG = LoggerFactory.getLogger(ComparisonImpl.class); > + > + private final static boolean CONVERT_LIKE_TO_RANGE = > Boolean.getBoolean("oak.convertLikeToRange"); > + > + static { > + LOG.info("Converting like to range queries is " + > (CONVERT_LIKE_TO_RANGE ? "enabled" : "disabled")); > + } > > private final DynamicOperandImpl operand1; > private final Operator operator; > @@ -193,7 +203,7 @@ > if (lowerBound.equals(upperBound)) { > // no wildcards > operand1.restrict(f, Operator.EQUAL, v); > - } else if (operand1.supportsRangeConditions()) { > + } else if (operand1.supportsRangeConditions() && > CONVERT_LIKE_TO_RANGE) { > if (lowerBound != null) { > PropertyValue pv = > PropertyValues.newString(lowerBound); > operand1.restrict(f, Operator.GREATER_OR_EQUAL, > pv); > @@ -203,7 +213,7 @@ > operand1.restrict(f, Operator.LESS_OR_EQUAL, pv); > } > } else { > - // path conditions > + // path conditions, or conversion is disabled > operand1.restrict(f, operator, v); > } > } else { > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)