use of org.opensearch.common.ParsingException in project OpenSearch by opensearch-project.
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.opensearch.common.ParsingException in project OpenSearch by opensearch-project.
the class MultiMatchQueryBuilderTests method testQueryParameterArrayException.
public void testQueryParameterArrayException() {
String json = "{\n" + " \"multi_match\" : {\n" + " \"query\" : [\"quick\", \"brown\", \"fox\"]\n" + " \"fields\" : [ \"title^1.0\", \"title.original^1.0\", \"title.shingles^1.0\" ]" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[multi_match] unknown token [START_ARRAY] after [query]", e.getMessage());
}
use of org.opensearch.common.ParsingException in project OpenSearch by opensearch-project.
the class PrefixQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"prefix\": {\n" + " \"user1\": {\n" + " \"value\": \"ki\"\n" + " },\n" + " \"user2\": {\n" + " \"value\": \"ki\"\n" + " }\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[prefix] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
String shortJson = "{\n" + " \"prefix\": {\n" + " \"user1\": \"ki\",\n" + " \"user2\": \"ki\"\n" + " }\n" + "}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[prefix] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
}
use of org.opensearch.common.ParsingException in project OpenSearch by opensearch-project.
the class RegexpQueryBuilderTests method testParseFailsWithMultipleFields.
public void testParseFailsWithMultipleFields() throws IOException {
String json = "{\n" + " \"regexp\": {\n" + " \"user1\": {\n" + " \"value\": \"k.*y\"\n" + " },\n" + " \"user2\": {\n" + " \"value\": \"k.*y\"\n" + " }\n" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[regexp] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
String shortJson = "{\n" + " \"regexp\": {\n" + " \"user1\": \"k.*y\",\n" + " \"user2\": \"k.*y\"\n" + " }\n" + "}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[regexp] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
}
use of org.opensearch.common.ParsingException in project OpenSearch by opensearch-project.
the class ScriptQueryBuilderTests method testArrayOfScriptsException.
public void testArrayOfScriptsException() {
String json = "{\n" + " \"script\" : {\n" + " \"script\" : [ {\n" + " \"source\" : \"5\",\n" + " \"lang\" : \"mockscript\"\n" + " },\n" + " {\n" + " \"source\" : \"6\",\n" + " \"lang\" : \"mockscript\"\n" + " }\n ]" + " }\n" + "}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertThat(e.getMessage(), containsString("does not support an array of scripts"));
}
Aggregations