Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to create a pattern replace character filter without flags #886

Closed
kmessaoudi opened this issue Mar 7, 2024 · 0 comments · Fixed by #895
Closed

[BUG] Unable to create a pattern replace character filter without flags #886

kmessaoudi opened this issue Mar 7, 2024 · 0 comments · Fixed by #895
Labels
bug Something isn't working untriaged

Comments

@kmessaoudi
Copy link
Contributor

What is the bug?

We are trying to create a index using this library and trying to create a pattern replace character filter with no flags. This is generating an error.

How can one reproduce the bug?

It works properly directly via the API.

PUT test-charfilter
{
  "settings": {
    "analysis": {
      
      "analyzer": {
        "analyzer_fr_FR": {
          "filter": [
            "lowercase",
            "asciifolding",
            "remove_duplicates"
          ],
          "type": "custom",
          "tokenizer": "standard",
          "char_filter": [
            "special_char_filter"
          ]
        }
      },
      "char_filter": {
        "special_char_filter": {
          "pattern": """["@\$#&*{}\[\],\.\=\+\-_\(\);'/\?"]""",
          "type": "pattern_replace",
          "replacement": ""
        }
      }
    }
  }
}

we will get

{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "test-charfilter"
}

However, when using the lib :

// opensearchClient is injected through a bean
String templateSettings = "{"analysis":{"analyzer":{"analyzer_fr_FR":{"filter":["lowercase","asciifolding","remove_duplicates"],"type":"custom","tokenizer":"standard","char_filter":["special_char_filter"]}},"char_filter":{"special_char_filter":{"pattern":"""["@\$#&*{}\[\],\.\=\+\-_\(\);'/\?"]""","type":"pattern_replace","replacement":""}}}}";
JsonpMapper mapper = opensearchClient._transport().jsonpMapper();
JsonParser settingsParser =
      mapper
        .jsonProvider()
        .createParser(new StringReader(templateSettings));

IndexSettings indexSettings = IndexSettings._DESERIALIZER.deserialize(settingsParser, mapper);

return CreateIndexRequest.Builder()
      .settings(indexSettings)
      .build();

We will get this error

org.opensearch.client.util.MissingRequiredPropertyException - Missing required property 'PatternReplaceCharFilter.flags'

When checking the class opensearch PatternReplaceCharFilter flags is required

this.flags = ApiTypeHelper.requireNonNull(builder.flags, this, "flags");

However on the class elastic PatternReplaceCharFilter flags is not required

What is the expected behavior?

The expected behavior is to be able to build a PatternReplaceCharFilter with no flags or at least know what is the default value to use.

What is your host/environment?

Tested with

  • a docker environment with opensearchproject/opensearch:2.11.1
  • Library opensearch-java in version 2.9.0

Do you have any screenshots?

N/A

Do you have any additional context?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant