use of org.elasticsearch.common.ParsingException in project elasticsearch by elastic.
the class MatchPhraseQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"match_phrase\" : {\n" + " \"message1\" : {\n" + " \"query\" : \"this is a test\"\n" + " },\n" + " \"message2\" : {\n" + " \"query\" : \"this is a test\"\n" + " }\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[match_phrase] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
String shortJson = "{\n" + " \"match_phrase\" : {\n" + " \"message1\" : \"this is a test\",\n" + " \"message2\" : \"this is a test\"\n" + " }\n" + "}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[match_phrase] 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 RangeQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"range\": {\n" + " \"age\": {\n" + " \"gte\": 30,\n" + " \"lte\": 40\n" + " },\n" + " \"price\": {\n" + " \"gte\": 10,\n" + " \"lte\": 30\n" + " }\n" + " }\n" + " }";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[range] query doesn't support multiple fields, found [age] and [price]", e.getMessage());
}
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."));
}
Aggregations