Refactors PrefixQuery#12032
Conversation
There was a problem hiding this comment.
out of curiosity, why do we have a newRandomQueryBuilder method here?
There was a problem hiding this comment.
I was actually thinking that this could later be moved as a helper method in the BaseQueryTestCase class, something that returns a random field name together with its value.
|
left a couple of small comments |
There was a problem hiding this comment.
Should this be rewrite field instead of fieldName (mentioned twice)
There was a problem hiding this comment.
Thanks good catch!
|
@javanna @cbuescher Thanks for the review. I updated the PR accordingly. |
|
looks good to me, @cbuescher can you have a final look plese? |
There was a problem hiding this comment.
This can't happen, and if for some reason after the switch fielname/value are unassigned the returned query will throw exceptions at some point (validation, doXContent, toQuery), so given this is a test method I'd remove it.
|
Did another round of reviews, left just two question/comments regarding setup of test query, otherwise looks good. |
The parser takes an Object value, so should the builder. Relates to elastic#12032
b882a2d to
0aaac85
Compare
|
@javanna @cbuescher Thanks for the review. I rebased the PR and updated it. |
There was a problem hiding this comment.
Could also reuse the BaseTermQueryBuilder#validate here? I realize we agreed on always overwriting this for the AbstractQueryBuilder, but since this just repeats the super types implementation, maybe we should call it?
|
left a couple of minor comments, I would wait for #12124 (or corresponding adapted PR) before getting this in though. |
There was a problem hiding this comment.
I don't know if it's possible to also extend the generic BaseTermQueryTestCase here, since a lot of the setup looks similar. That one is also testing Boolean as a value type while this test adds Date there. Maybe the creation of the expected query gets a bit too complicated, but the two existing Test classes (SpanTermQueryBuilderTest, TermQueryBuilderTest) are quiet small that way. Might be worth looking into merging, unless you already tried and found it to hard to read afterwards.
There was a problem hiding this comment.
Patially revoking my last comment, I would only try this and add the inheritance level in the test if in the end you decide to have PrefixQueryBuilder extend BaseTermQueryBuilder. Thinking about it a bit more, I'm not sure if this is maybe growing to complex at this point and a bit of code duplication should be traded for ease of understanding.
There was a problem hiding this comment.
+1 for using BaseTermQueryTestCase
There was a problem hiding this comment.
if PrefixQueryBuilder won't extend BaseTermQueryBuilder anymore I think we can't extend BaseTermQueryTestCase either here
There was a problem hiding this comment.
It might be possible, but I would try to avoid it in this case. I would go for either using both BaseTerm classes or none.
There was a problem hiding this comment.
OK then we go for none? I am ok either way.
There was a problem hiding this comment.
I would leave it as-is, it needs to extend BaseQueryTestCase
|
Also did another round and left a couple of comments. |
0aaac85 to
4997b9e
Compare
|
@javanna Thanks for the review. I rebased and updated the PR accordingly. |
There was a problem hiding this comment.
we can revert these two changes no given that we dont' extend from this class anymore?
There was a problem hiding this comment.
I think we should allow these to be overridden, but I'm happy to make the change.
There was a problem hiding this comment.
well we don't need to extend this anywhere, plus these changes don't have anything to do with this PR at this point, would prefer to leave them out.
There was a problem hiding this comment.
sure I'll revert this change.
|
@javanna Thanks for the review. We need to address #11865 (comment) before it can be pushed though, and waiting on #12204 as well. |
Relates to elastic#10217 Closes elastic#12032 This PR is against the query-refactoring branch.
8a75083 to
37c6347
Compare
|
@javanna it's rebased, you can take a look. Thank you. |
|
LGTM |
Relates to elastic#10217 Closes elastic#12032 This PR is against the query-refactoring branch.
Relates to #10217
This PR is against the query-refactoring branch.