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

Sort and refactor methods #389

Merged
merged 5 commits into from
Feb 5, 2024
Merged

Sort and refactor methods #389

merged 5 commits into from
Feb 5, 2024

Conversation

drmarjanovic
Copy link
Member

No description provided.

@drmarjanovic drmarjanovic marked this pull request as ready for review February 4, 2024 18:59
weight = None
)

/**
* Constructs an instance of [[zio.elasticsearch.query.RandomScoreFunction]] using the specified parameters.
* [[zio.elasticsearch.query.RandomScoreFunction]] generates scores that are uniformly distributed from 0 up to but
* not including 1. By default, it uses the internal Lucene doc IDs as a source of randomness, which is very efficient
* not including 1. By default, it uses the internal Lucene doc ids as a source of randomness, which is very efficient
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* not including 1. By default, it uses the internal Lucene doc ids as a source of randomness, which is very efficient
* not including 1. By default, it uses the internal Lucene doc IDs as a source of randomness, which is very efficient

Comment on lines 540 to 548
def filter[S1 <: S: Schema](filter: ElasticQuery[S1]): FieldValueFactor[S1] =
FieldValueFactor[S1](
field = self.field,
factor = self.factor,
filter = Some(filter),
modifier = self.modifier,
missing = self.missing,
weight = self.weight
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you use self.copy(filter = Some(filter))?

Comment on lines 550 to 558
def filter(value: ElasticQuery[Any]): FieldValueFactor[Any] =
FieldValueFactor(
field = self.field,
factor = self.factor,
filter = Some(value),
modifier = self.modifier,
missing = self.missing,
weight = self.weight
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here also.

@@ -627,6 +628,12 @@ private[elasticsearch] final case class RandomScoreFunction[S](
weight: Option[Double]
) extends FunctionScoreFunction[S] { self =>

def filter[S1 <: S: Schema](filter: ElasticQuery[S1]): RandomScoreFunction[S1] =
RandomScoreFunction[S1](Some(filter), seedAndField, weight)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Name parameters.

val includes = if (included.isEmpty) Obj() else Obj("includes" -> Arr(included.map(_.toJson)))
val excludes = if (excluded.isEmpty) Obj() else Obj("excludes" -> Arr(excluded.map(_.toJson)))
Some(includes merge excludes)
case (Chunk(), Chunk()) => None
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we can put None in the new line, just to be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are. Everything is inlined here.

@mvelimir mvelimir merged commit 769728d into main Feb 5, 2024
13 checks passed
@mvelimir mvelimir deleted the sort-and-refactor-methods branch February 5, 2024 14:29
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