Skip to content

[BUG] COMPLEMENT does not work in Regexp queries #18397

@kolchfa-aws

Description

@kolchfa-aws

Describe the bug

The COMPLEMENT value in RegexpFlag is not working. The code refers to deprecated complement in Lucene https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/query/RegexpFlag.java#L66. See related Lucene pull apache/lucene#13739.

Related component

No response

To Reproduce

When documenting regex syntax, I ran the following example to test the COMPLEMENT value of the flags parameter:

PUT /test/_doc/1
{
  "text": "abc"
}

PUT /test/_doc/2
{
  "text": "adc"
}

PUT /test/_doc/3
{
  "text": "acc"
}

GET /test/_search
{
  "query": {
    "regexp": {
      "text.keyword": {
        "value": "a~bc",
        "flags": "COMPLEMENT"
      }
    }
  }
}

The query returns no results.

Expected behavior

I'm expecting adc and acc to be returned.

Additional Details

OpenSearch 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    SearchSearch query, autocomplete ...etcbugSomething isn't workinglucene

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions