Skip to content
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

Merged

Conversation

markaya
Copy link
Contributor

@markaya markaya commented May 11, 2023

Summary:

Implemented idea for creating ElasticUtilities object that would contain methods to create objects such as Script or InnerHits that do not belong to any other objects.

Copy link
Member

@drmarjanovic drmarjanovic left a 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.

@markaya markaya force-pushed the task-create-public-methods-for-Script-and-InnerHits branch from fdcb9ed to de9f324 Compare May 17, 2023 08:51
@markaya markaya force-pushed the task-create-public-methods-for-Script-and-InnerHits branch from de9f324 to 7d38125 Compare May 17, 2023 09:12
@markaya markaya marked this pull request as ready for review May 17, 2023 10:04
dbulaja98
dbulaja98 previously approved these changes May 17, 2023

def name(value: String): InnerHits =
InnerHits(name = Some(value))
def withName(value: String): InnerHits =
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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 =
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@drmarjanovic drmarjanovic merged commit e4d9c87 into main May 18, 2023
@drmarjanovic drmarjanovic deleted the task-create-public-methods-for-Script-and-InnerHits branch May 18, 2023 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants