use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class WildcardQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"wildcard\": {\n" + " \"user1\": {\n" + " \"wildcard\": \"ki*y\"\n" + " },\n" + " \"user2\": {\n" + " \"wildcard\": \"ki*y\"\n" + " }\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[wildcard] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
String shortJson = "{\n" + " \"wildcard\": {\n" + " \"user1\": \"ki*y\",\n" + " \"user2\": \"ki*y\"\n" + " }\n" + "}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[wildcard] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
}
use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class FunctionScoreQueryBuilderTests method expectParsingException.
private void expectParsingException(String json, Matcher<String> messageMatcher) {
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertThat(e.getMessage(), messageMatcher);
}
use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class FunctionScoreQueryBuilderTests method testProperErrorMessageWhenMissingFunction.
public void testProperErrorMessageWhenMissingFunction() throws IOException {
String functionScoreQuery = "{\n" + " \"function_score\":{\n" + " \"functions\": [\n" + " {\n" + " \"filter\": {\n" + " \"term\":{\n" + " \"field2\":\"value2\"\n" + " }\n" + " }\n" + " }\n" + " ]\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(functionScoreQuery));
assertThat(e.getMessage(), containsString("an entry in functions list is missing a function."));
}
use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class SpanTermQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"span_term\" : {\n" + " \"message1\" : {\n" + " \"term\" : \"this\"\n" + " },\n" + " \"message2\" : {\n" + " \"term\" : \"this\"\n" + " }\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[span_term] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
String shortJson = "{\n" + " \"span_term\" : {\n" + " \"message1\" : \"this\",\n" + " \"message2\" : \"this\"\n" + " }\n" + "}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[span_term] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
}
use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class TermQueryBuilderTests method testTermArray.
public void testTermArray() throws IOException {
String queryAsString = "{\n" + " \"term\": {\n" + " \"age\": [34, 35]\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(queryAsString));
assertEquals("[term] query does not support array of values", e.getMessage());
}
Aggregations