-
Notifications
You must be signed in to change notification settings - Fork 18
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
Create public methods for script and inner hits #216
Create public methods for script and inner hits #216
Conversation
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.
Why not use a companion object? If it does not work right now, we can make only the constructor private and create it through the apply
method.
fdcb9ed
to
de9f324
Compare
de9f324
to
7d38125
Compare
|
||
def name(value: String): InnerHits = | ||
InnerHits(name = Some(value)) | ||
def withName(value: String): InnerHits = |
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.
Why is this changed? Not sorted.
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.
It does not make sense to me when creating new InnerHits to say just InnerHits.name(...)
, withName
made more sense. I would consider doing same for form
and size
. What do you think?
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.
I think we are trying to avoid with
prefix. @arnoldlacko?
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.
Maybe we could drop all these and just have InnerHits.empty.name(...).from(...)
?
@@ -57,6 +57,6 @@ private[elasticsearch] final case class Script( | |||
} | |||
|
|||
object Script { | |||
def apply(source: String): Script = | |||
def from(source: String): Script = |
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.
Why use from
instead of apply
?
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 agreed earlier that overriding apply
method is not something we want to be doing as it makes false feeling that Script has only one field.
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.
I would consider source
as a required param. And if we have Script("source")
then we can consider it as a wrapper on the string. I would use apply
.
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.
Sure. I will change it to apply
.
Summary:
Implemented idea for creating
ElasticUtilities
object that would contain methods to create objects such asScript
orInnerHits
that do not belong to any other objects.