Newbie here. I want to be able to take a
ClusterState retrieved as usual via
ClusterAdminClient, serialize it to a human-readable file via
toXContent then recreate it at a later date from that file. Serializing is straightforward, but after several hours of Googling and hunting through ES source I can't see a way to deserialize back again;
XContentParser looks as if it can parse out weakly-typed maps etc, but not specific types like
MetaData would also be fine - that's the only part I'm interested in - but since
MetaData doesn't even implement
ToXContent that looked like a non-starter.
Background/context: I'm trying to build unit tests around an existing system that uses index mapping metadata to drive logic. For obvious reasons I don't want to make live ES calls when running unit tests, so the plan was to use canned data instead. Since real metadata is often huge I'd quite like to be able to reduce or construct minimal mappings to test particular edge cases; I'd also like to be able to see the canned data driving a particular test. This is why I really want human-readability;
readFrom work fine but produce unreadable binary soup.
Am I barking up the wrong tree, and/or fundamentally misunderstanding what the XContent format is about? I got the impression that it's an abstraction of serialization formats supporting round-tripping, but as I said, newbie.