Skip to content

Remaining queries for long script field #59816

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

Merged

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Jul 17, 2020

Adds the terms and range queries for long typed script fields.
It also fixes a bug in a few of toString tests for keyword typed
script fields.

Relates to #59332

Adds the `terms` and `range` queries for `long` typed `script` fields.
It also fixes a bug in a few of `toString` tests for `keyword` typed
`script` fields.
@nik9000 nik9000 added the :Search/Search Search-related issues that do not fall into other categories label Jul 17, 2020
@nik9000 nik9000 requested a review from javanna July 17, 2020 21:26
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jul 17, 2020
@javanna javanna mentioned this pull request Jul 17, 2020
30 tasks
@nik9000
Copy link
Member Author

nik9000 commented Jul 20, 2020

Looks like the test failure on this one is real. I'll have a look.

@nik9000
Copy link
Member Author

nik9000 commented Jul 20, 2020

Looks like the test failure on this one is real. I'll have a look.

I've pushed an update!

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left one comment around the changes to NumberFieldMapper. LGTM otherwise

@@ -906,6 +880,51 @@ public static long objectToLong(Object value, boolean coerce) {
String stringValue = (value instanceof BytesRef) ? ((BytesRef) value).utf8ToString() : value.toString();
return Numbers.toLong(stringValue, coerce);
}

@FunctionalInterface
public interface RangeQueryBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions are cool, but couldn't we have a shared method that does the boiler-plate range conversion, which is called when creating the lucene query?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potentially, that could even be pushed upstream? I would love to not have changes to this mapper as part of the feature branch, if possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Elasticsearch is mostly responsible for the Object to long stuff. I don't think that is something Lucene wants but I could certainly be wrong.

I would love to not have changes to this mapper as part of the feature branch, if possible.

I could copy and paste the code but I think that'd be dangerous as it'd get out of sync if someone made a chance to the mapper.

functions are cool, but couldn't we have a shared method that does the boiler-plate range conversion, which is called when creating the lucene query?

I think that is what this is. I could probably write it in a way that doesn't use the functional interface if you'd prefer, but it'll be a little more jumbled. It might still be more clear just because we avoid the indirection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I was not too careful looking, but it looked like you were calling the function last in the method, which made me think that you could rather have one method to convert the ranges, though what is the return type of that method going to be? Maybe I start to see how a function simplifies it. I don't have a strong opinion. Maybe make it a BiFunction ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a BiFunction. Do you think that is better?

Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nik9000 nik9000 merged commit 0589d2e into elastic:feature/runtime_fields Jul 20, 2020
@nik9000
Copy link
Member Author

nik9000 commented Jul 20, 2020

Thanks @javanna !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants