-
Notifications
You must be signed in to change notification settings - Fork 267
Description
Description
Hi,
I am trying to migrate some of our code to the new client. In one of our indices we have the following mapping:
{
"properties": {
"polygoon": {
"type": "geo_shape"
}
}
}
The index with mapping itself I can create successfully using the new builders:
TypeMapping.of(mappings -> mappings.properties("polygoon", polygoon -> polygoon.geoShape(s -> s))
What I can't get to find out is what the Java representation of the geo-shape should be. It seems to me that the geo-shape value should be of type JsonData
:
import co.elastic.clients.json.JsonData;
import java.util.UUID;
@Getter //lombok
@Setter //lombok
public class ExampleDocument {
private UUID id;
private JsonData polygoon;
}
The call to create the document:
client.create(r -> r
.index("index-name")
.id(id.toString())
.document(doc)
.refresh(Refresh.True)
)
But this returns me with the following error response when saving this document:
[es/create] failed: [mapper_parsing_exception] failed to parse field [polygoon] of type [geo_shape]
Client + Json mapper is pretty much default:
return new ElasticsearchClient(new RestClientTransport(elasticsearchLowLevelClient().build(), new JacksonJsonpMapper()));
Any help would be greatly appreciated.
Edit:
At this point i'm fairly certain that it should be of type JsonData
since the same data type is used in GeoShapeFieldQuery
for shape
as well.
I think my error is mainly somewhere in constructing a JsonData
object. Which looks like this:
public static JsonData convertToJsonData(String polygoon) {
return JsonData.of(polygoon, new JacksonJsonpMapper());
}