Added exception if passed an invalid type param

Closes #4964
This commit is contained in:
markharwood 2014-01-31 15:21:06 +00:00
parent 1ca565cf9f
commit 5f8dbeaa8e
2 changed files with 7 additions and 2 deletions

View File

@ -92,6 +92,8 @@ public class MatchQueryParser implements QueryParser {
type = MatchQuery.Type.PHRASE;
} else if ("phrase_prefix".equals(tStr) || "phrasePrefix".equals(currentFieldName)) {
type = MatchQuery.Type.PHRASE_PREFIX;
} else {
throw new QueryParsingException(parseContext.index(), "[match] query does not support type " + tStr);
}
} else if ("analyzer".equals(currentFieldName)) {
String analyzer = parser.text();

View File

@ -76,7 +76,8 @@ public class MultiMatchQueryParser implements QueryParser {
} else if (token.isValue()) {
extractFieldAndBoost(parseContext, parser, fieldNameWithBoosts);
} else {
throw new QueryParsingException(parseContext.index(), "[query_string] query does not support [" + currentFieldName + "]");
throw new QueryParsingException(parseContext.index(), "[" + NAME + "] query does not support [" + currentFieldName
+ "]");
}
} else if (token.isValue()) {
if ("query".equals(currentFieldName)) {
@ -89,11 +90,13 @@ public class MultiMatchQueryParser implements QueryParser {
type = MatchQuery.Type.PHRASE;
} else if ("phrase_prefix".equals(tStr) || "phrasePrefix".equals(currentFieldName)) {
type = MatchQuery.Type.PHRASE_PREFIX;
} else {
throw new QueryParsingException(parseContext.index(), "[" + NAME + "] query does not support type " + tStr);
}
} else if ("analyzer".equals(currentFieldName)) {
String analyzer = parser.text();
if (parseContext.analysisService().analyzer(analyzer) == null) {
throw new QueryParsingException(parseContext.index(), "[match] analyzer [" + parser.text() + "] not found");
throw new QueryParsingException(parseContext.index(), "["+ NAME +"] analyzer [" + parser.text() + "] not found");
}
multiMatchQuery.setAnalyzer(analyzer);
} else if ("boost".equals(currentFieldName)) {