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] Shape property doesn't work, should be XyShape #884

Closed
grouh opened this issue Mar 7, 2024 · 0 comments · Fixed by #885
Closed

[BUG] Shape property doesn't work, should be XyShape #884

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

Comments

@grouh
Copy link
Contributor

grouh commented Mar 7, 2024

What is the bug?

When using the shape property with the opensearch java client, this result as an error as it is known to OpenSearch, where this feature has the name xy_shape

How can one reproduce the bug?

In OpenSearch

{
  "mappings": {
    "properties": {
      "myshapeprop": {
        "type": "shape"
      }
    }
  }
}

Will result in the following error

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "No handler for type [shape] declared on field [myshapeprop]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: No handler for type [shape] declared on field [myshapeprop]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "No handler for type [shape] declared on field [myshapeprop]"
    }
  },
  "status": 400
}

When using the xy_shape property, it works properly

PUT index_with_shape
{
  "mappings": {
    "properties": {
      "myshapeprop": {
        "type": "xy_shape"
      }
    }
  }
}

Will get

{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "index_with_shape"
}

This due to Shape Elasticearch Feature
being implemented as XY Shape in Opensearch

When using the Opensearch Java client

// opensearchClient is injected through a bean
String templateMapping = "{"properties":{"myshapeprop": {"type": "xy_shape"}}}";
JsonpMapper mapper = opensearchClient._transport().jsonpMapper();
JsonParser mappingsParser =
      mapper
        .jsonProvider()
        .createParser(new StringReader(templateMapping));

TypeMapping typeMapping = TypeMapping._DESERIALIZER.deserialize(mappingsParser, mapper);

return CreateIndexRequest.Builder()
      .mappings(typeMapping)
      .build();

Will result in the following error

[org.opensearch.client.util.MissingRequiredPropertyException - Missing required property 'Builder.<variant kind>']

What is the expected behavior?

Expected behavior is for Index to be created with the xy_shape property

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