Skip to content

Commit

Permalink
Bug no. 2 is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Solitaire96 committed Mar 12, 2015
1 parent a19335c commit 99dcb3a
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* }
* </pre>
*/


public class FieldValueFactorFunctionParser implements ScoreFunctionParser {
public static String[] NAMES = { "field_value_factor", "fieldValueFactor" };

Expand All @@ -60,7 +62,15 @@ public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
}
/*
Error here is thrown, as field_value_factor should not accept array params
Bug #2
*/
else if(token == XContentParser.Token.START_ARRAY) {
throw new QueryParsingException(parseContext.index(), NAMES[0] + " query does not accept arrays");
}
else if (token.isValue()) {
if ("field".equals(currentFieldName)) {
field = parser.text();
} else if ("factor".equals(currentFieldName)) {
Expand All @@ -77,6 +87,7 @@ public ScoreFunction parse(QueryParseContext parseContext, XContentParser parser
throw new QueryParsingException(parseContext.index(), "[" + NAMES[0] + "] required field 'field' missing");
}


SearchContext searchContext = SearchContext.current();
FieldMapper mapper = searchContext.mapperService().smartNameFieldMapper(field);
if (mapper == null) {
Expand Down

0 comments on commit 99dcb3a

Please sign in to comment.