New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function score parser should throw exception if both functions:[]
and single function
given
#5995
Conversation
We might want to consider treating the following case as a special case
because the name "boost" and "boost_factor" are pretty similar. The error message could be the same with the addition "... Did you mean "boost" instead?" |
client().search( | ||
searchRequest().source( | ||
searchSource().query(query))).actionGet(); | ||
assertFalse(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail()
should work as well
LGTM
This would be nice indeed. I can easily see some confusion here. |
Thanks for the review! Iadded two commits implementing the suggestions. |
// For better readability of error message | ||
String singleFunctionName = null; | ||
final String errorMessagePrefix = "You can either define \"functions\":[...] or a single function, not both. "; | ||
final String boostNameMessageSuffix = " Did you mean \"boost\" instead?"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have these two variables as constants instead?
OK, added new commit to remove the duplicate code and make the strings constant |
@@ -46,6 +49,9 @@ | |||
|
|||
public static final String NAME = "function_score"; | |||
ScoreFunctionParserMapper funtionParserMapper; | |||
// For better readability of error message | |||
static final String misplacedFunctionMessagePrefix = "You can either define \"functions\":[...] or a single function, not both. "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually use upper case and underscore case for contants, see eg. NAME
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would give MISPLACED_FUNCTION_MESSAGE_PREFIX
Apart from a minor formatting issue, this looks good to me! |
…e function given In addition, add a special warning if the misplaced function is a "boost_factor" function to avoid confusion of "boost" and "boost_function". closes #5995
functions:[]
and single function
given
No description provided.