xuzifu666 commented on code in PR #4434:
URL: https://github.com/apache/calcite/pull/4434#discussion_r2163375484


##########
elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/QueryBuilders.java:
##########
@@ -499,12 +501,27 @@ static class RegexpQueryBuilder extends QueryBuilder {
     private final String value;
 
     RegexpQueryBuilder(final String fieldName, final String value) {
+      requireNonNull(fieldName, "fieldName");
+      requireNonNull(value, "value");
       this.fieldName = fieldName;
-      this.value = value;
+      // replace % to * and _ to ? for sql with like operator
+      this.value = replaceWildcard(replaceWildcard(value, "%", "*"), "_", "?");

Review Comment:
   I made the following changes:
   1. LIKE in ElasticSearch supports escape parameter;
   2. Added a function to support escape character recognition (current tools 
probably don’t have a direct support method), so I wrote one myself: 
```RegexpQueryBuilder.replaceWildcard```;
   3. Added more test cases, such as the case containing the escape parameter, 
and unit tests ```testReplaceWildcard```  for the 
```RegexpQueryBuilder.replaceWildcard``` method, PTAL 



-- 
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]

Reply via email to