I'm wondering how feasible it is to use some of the Java classes defined by Elasticsearch on the client side, rather than building up JSON strings or XContentBuilder instances manually. Specifically, I'm wondering about creating mappings. It would be really nice if I could create a DocumentMapper instance (which implements ToXContent) to define a mapping, and then use that to create an XContentBuilder to pass to setSource on PutMappingRequestBuilder.
This would be great, since it would rely on existing types to ensure that valid mappings are created, rather than leaving open the possibility of incorrectly constructing JSON (either via typos or incorrect field names, or just incorrect structure). However, I'm having trouble figuring out whether this is possible or intended; it seems to create a DocumentMapper instance, I'd need a DocumentMapper.Builder instance, which requires a DocumentMapperParser instance to build the DocumentMapper, and the DocumentMapperParser instance in turn requires a number of other objects not readily available. Am I basically stuck with writing my own code to generate these JSON structures? If so, it'd be really nice in the future if the Java API would leverage the fact that much of the code is already used on the server side, and make those classes easily available for clients to leverage static typing to help ensure correctness. Thanks. -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8cbf0f15-a5d2-4dda-9759-ede3505ca08e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
