Throw parsing error if fuzzy query contains multiple fields in its short version
This commit is contained in:
parent
1db3c67e31
commit
5d238e86f6
|
@ -309,6 +309,10 @@ public class FuzzyQueryBuilder extends AbstractQueryBuilder<FuzzyQueryBuilder> i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (fieldName != null) {
|
||||||
|
throw new ParsingException(parser.getTokenLocation(), "[fuzzy] query doesn't support multiple fields, found ["
|
||||||
|
+ fieldName + "] and [" + parser.currentName() + "]");
|
||||||
|
}
|
||||||
fieldName = parser.currentName();
|
fieldName = parser.currentName();
|
||||||
value = parser.objectBytes();
|
value = parser.objectBytes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,5 +169,15 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase<FuzzyQueryBuil
|
||||||
|
|
||||||
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
|
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
|
||||||
assertEquals("[fuzzy] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
assertEquals("[fuzzy] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
||||||
|
|
||||||
|
String shortJson = "{\n" +
|
||||||
|
" \"fuzzy\" : {\n" +
|
||||||
|
" \"message1\" : \"this is a test\",\n" +
|
||||||
|
" \"message2\" : \"value\" : \"this is a test\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
|
||||||
|
assertEquals("[fuzzy] query doesn't support multiple fields, found [message1] and [message2]", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue