AnalyzeRequest analyzeRequest = new AnalyzeRequest("for test");
BytesReference invalidExplain = XContentFactory.jsonBuilder()
.startObject()
.field("explain", "fals")
.endObject().bytes();
<BUG>try {
RestAnalyzeAction.buildFromContent(invalidExplain, analyzeRequest, new ParseFieldMatcher(Settings.EMPTY));

fail("shouldn't get here");
} catch (Exception e) {
assertThat(e, instanceOf(IllegalArgumentException.class));</BUG>
assertThat(e.getMessage(), startsWith("explain must be either 'true' or 'false'"));

AnalyzeRequest analyzeRequest = new AnalyzeRequest("for test");
BytesReference invalidContent = XContentFactory.jsonBuilder()
.startObject()
.field("text", "THIS IS A TEST")
.field("unknown", "keyword")
.endObject().bytes();
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> RestAnalyzeAction.buildFromContent(invalidContent, analyzeRequest, new ParseFieldMatcher(Settings.EMPTY)));
assertThat(e.getMessage(), startsWith("Unknown parameter [unknown]"));
