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

(dsl): Support Function Score Query #224

Merged
merged 18 commits into from
May 30, 2023
Merged

Conversation

markaya
Copy link
Contributor

@markaya markaya commented May 18, 2023

No description provided.

@markaya markaya force-pushed the task-support-function-score-query branch 2 times, most recently from 15b37f6 to c730d63 Compare May 23, 2023 13:34
@markaya markaya force-pushed the task-support-function-score-query branch from c730d63 to 4a38eb1 Compare May 25, 2023 08:31
Chunk(
Some("functions" -> Arr(functionScoreFunctions.map(_.toJson))),
boost.map("boost" -> Num(_)),
boostMode.map(bm => "boost_mode" -> Str(s"${bm.toString.toLowerCase}")),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
boostMode.map(bm => "boost_mode" -> Str(s"${bm.toString.toLowerCase}")),
boostMode.map(bm => "boost_mode" -> Str(bm.toString.toLowerCase)),

Copy link
Collaborator

@dbulaja98 dbulaja98 May 28, 2023

Choose a reason for hiding this comment

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

Can you also change Str(bm.toString.toLowerCase)) to bm.toString.toLowerCase.toJson?
Also change this in other places, if any.

@markaya markaya force-pushed the task-support-function-score-query branch from faf44e7 to a268162 Compare May 29, 2023 14:23
* the [[zio.elasticsearch.query.ElasticQuery]] used for filtering
* @return
* an instance of [[zio.elasticsearch.query.FunctionScoreFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] ] to be performed enriched with the `filter` parameter.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] ] to be performed enriched with the `filter` parameter.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed enriched with the `filter` parameter.

* the type of query used in filter, requires implicit [[zio.schema.Schema]] in scope
* @return
* an instance of [[zio.elasticsearch.query.FunctionScoreFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed enriched with the `filter` parameter.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed enriched with the `filter` parameter.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed enriched with the `filter` parameter.

* defines the distance from origin + offset at which the computed score will equal `decay` parameter
* @return
* an instance of [[zio.elasticsearch.query.DecayFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed.

* defines the distance from origin + offset at which the computed score will equal `decay`
* @return
* an instance of [[zio.elasticsearch.query.DecayFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed.

/**
* Constructs a type-safe instance of [[zio.elasticsearch.query.FieldValueFactor]] using the specified parameters.
* [[zio.elasticsearch.query.FieldValueFactor]] function allows you to use a field from a document to influence the
* score. It is similar to using the script_score function, however, it avoids the overhead of scripting. If used on a
Copy link
Member

Choose a reason for hiding this comment

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

Should we better reference the script_score function?

* the final score will be computed based on this value and default value for `field` which is "_seq_no"
* @return
* an instance of [[zio.elasticsearch.query.RandomScoreFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed.

* the field value that will be used to compute final score
* @return
* an instance of [[zio.elasticsearch.query.RandomScoreFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed.

/**
* 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
Copy link
Member

Choose a reason for hiding this comment

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

document IDs

* the type-safe field for which [[zio.elasticsearch.query.RandomScoreFunction]] is specified for
* @return
* an instance of [[zio.elasticsearch.query.RandomScoreFunction]] that can be used in
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* [[zio.elasticsearch.query.FunctionScoreQuery] to be performed.
* [[zio.elasticsearch.query.FunctionScoreQuery]] to be performed.


/**
* Sets the `scoreMode` parameter for the [[zio.elasticsearch.query.FunctionScoreQuery]]. The `scoreMode` parameter
* specifies how the computed scores are combined
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* specifies how the computed scores are combined
* specifies how the computed scores are combined.

drmarjanovic
drmarjanovic previously approved these changes May 30, 2023
Comment on lines 128 to 129
* Constructs a type-safe instance of [[zio.elasticsearch.query.FunctionScore]] query with one or multiple
* [[zio.elasticsearch.query.FunctionScoreFunction]]
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
* Constructs a type-safe instance of [[zio.elasticsearch.query.FunctionScore]] query with one or multiple
* [[zio.elasticsearch.query.FunctionScoreFunction]]
* Constructs a type-safe instance of [[zio.elasticsearch.query.FunctionScore]] query with one or multiple
* [[zio.elasticsearch.query.FunctionScoreFunction]].

* [[zio.elasticsearch.query.FunctionScore]] query
* @return
* an instance of [[zio.elasticsearch.query.FunctionScore]] that represents the Function Score Query with functions
* that are used to calculate score for result
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
* that are used to calculate score for result
* that are used to calculate score for result.


/**
* Constructs an instance of [[zio.elasticsearch.query.FunctionScore]] query with one or multiple
* [[zio.elasticsearch.query.FunctionScoreFunction]]
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
* [[zio.elasticsearch.query.FunctionScoreFunction]]
* [[zio.elasticsearch.query.FunctionScoreFunction]].

* [[zio.elasticsearch.query.FunctionScore]] query
* @return
* an instance of [[zio.elasticsearch.query.FunctionScore]] that represents the Function Score Query with functions
* that are used to calculate score for result
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
* that are used to calculate score for result
* that are used to calculate score for result.

* [[zio.elasticsearch.query.WeightFunction]] score allows you to multiply the score by the provided `weight`.
*
* @param weight
* the number you wish to multiply the score with
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
* the number you wish to multiply the score with
* the non-negative real number you wish to multiply the score with

@@ -310,9 +444,9 @@ sealed trait HasChildQuery[S]
* limit, it is excluded from the search results.
*
* @param value
* the [[scala.Int]] value for `score` parameter
* the [[scala.Int]] value for `minChildren` parameter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe:

Suggested change
* the [[scala.Int]] value for `minChildren` parameter
* the whole number value for `minChildren` parameter

@dbulaja98 dbulaja98 merged commit 1e5f9b1 into main May 30, 2023
@dbulaja98 dbulaja98 deleted the task-support-function-score-query branch May 30, 2023 10:41
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