Skip to content

Commit e1ea812

Browse files
Update changelog
Signed-off-by: Prudhvi Godithi <pgodithi@amazon.com>
1 parent b0563ad commit e1ea812

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3636
- [Autotagging] Fix delete rule event consumption in InMemoryRuleProcessingService ([#18628](https://github.com/opensearch-project/OpenSearch/pull/18628))
3737
- Cannot communicate with HTTP/2 when reactor-netty is enabled ([#18599](https://github.com/opensearch-project/OpenSearch/pull/18599))
3838
- Fix the visit of sub queries for HasParentQuery and HasChildQuery ([#18621](https://github.com/opensearch-project/OpenSearch/pull/18621))
39+
- Honor COMPLEMENT for Regexp queries ([#18640](https://github.com/opensearch-project/OpenSearch/pull/18640))
3940

4041

4142
### Security

gradle/run.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ testClusters {
5252
}
5353
}
5454
}
55+
setting 'logger.level', 'DEBUG'
5556
}
5657

5758
}

server/src/main/java/org/opensearch/index/query/RegexpQueryBuilder.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.lucene.search.RegexpQuery;
3939
import org.apache.lucene.util.automaton.Operations;
4040
import org.apache.lucene.util.automaton.RegExp;
41+
import org.opensearch.common.logging.DeprecationLogger;
4142
import org.opensearch.common.lucene.BytesRefs;
4243
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
4344
import org.opensearch.core.ParseField;
@@ -60,6 +61,9 @@
6061
* @opensearch.internal
6162
*/
6263
public class RegexpQueryBuilder extends AbstractQueryBuilder<RegexpQueryBuilder> implements MultiTermQueryBuilder {
64+
65+
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RegexpQueryBuilder.class);
66+
6367
public static final String NAME = "regexp";
6468

6569
public static final int DEFAULT_FLAGS_VALUE = RegexpFlag.ALL.value();
@@ -294,6 +298,18 @@ protected Query doToQuery(QueryShardContext context) throws QueryShardException,
294298
+ "] index level setting."
295299
);
296300
}
301+
302+
// Check if COMPLEMENT flag is being used
303+
// The COMPLEMENT flag maps to Lucene's DEPRECATED_COMPLEMENT which is marked for removal in Lucene 11
304+
// This deprecation warning helps users migrate their queries before the feature is completely removed
305+
if ((syntaxFlagsValue & RegexpFlag.COMPLEMENT.value()) != 0) {
306+
deprecationLogger.deprecate(
307+
"regexp_complement_operator",
308+
"The complement operator (~) for arbitrary patterns in regexp queries is deprecated and will be removed in a future version. "
309+
+ "Consider rewriting your query to use character class negation [^...] or other query types."
310+
);
311+
}
312+
297313
MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE);
298314

299315
int matchFlagsValue = caseInsensitive ? RegExp.ASCII_CASE_INSENSITIVE : 0;

0 commit comments

Comments
 (0)