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
field_value_factor accepts arrays values, does not throw error #7408
Comments
It seems a good one to start contributing. |
I tried it and I think the fix is pretty simple. The problem is that to test this it takes a newbie like me way more effort than to fix it. Any ideas? |
@cfontes you should be able to take a look at |
Whoops sorry, I misread your message about the testing being the hard part instead of the feature. You should be able to add a test in |
@dakrone thanks, I looked at that before and as I said it looks easy to fix. I ended up on those exact places. My problem is with testing this, because as far as I can see from my limited knowledge of ES code It would be great to have a mocking framework or some easy way to get those kinds of Objects for testing purpose. Is there any already in place that I couldn't find? |
@cfontes you should use an integration test for this instead of mocking everything out, see this test: https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/search/functionscore/FunctionScoreFieldValueTests.java#L41 the bottom section has some try/catches that catch invalid queries. |
@dakrone, thanks! I will! Any thoughts on why that should be tested as part of an integration test? It looks like a simple case of method internal validations that looks good in a Unit test. I don't want to be an ass or anything (sorry if it sounds like that...) just trying to understand the way you guys work. |
@cfontes no problem at all :) Usually it makes sense to integration test these sort of queries because you're testing for results returned instead of an exception being thrown, so having an integration framework where you can index some documents and check query results is useful. You can get the parseContext by using the injector to get the IndexService and unit test it if you'd like also, here's an example of getting one: https://github.com/elasticsearch/elasticsearch/blob/master/src/test/java/org/elasticsearch/index/search/FieldDataTermsFilterTests.java#L76-L80 , however, just getting the injector means starting up nodes so an integration test works just as well for this. If you do want to add a unit test for this that would be great, but not required. |
… a field_value_factor query closes elastic#7408
… a field_value_factor query closes #7408
In trying to figure out whether I could use multiple fields in a
field_value_factor
clause (which is not possible, I think?), I spotted a bug.Passing in arrays like so:
Leads to this being executed:
It might be better to throw an error if unexpected data types are passed in here.
As an aside, it would be great to be able to use multiple fields somehow in the
field_value_factor
to tune the score.The text was updated successfully, but these errors were encountered: