-
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
(dsl): Support Function Score Query #224
Conversation
modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/it/scala/zio/elasticsearch/HttpExecutorSpec.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/test/scala/zio/elasticsearch/FunctionScoreFunctionsSpec.scala
Show resolved
Hide resolved
15b37f6
to
c730d63
Compare
modules/library/src/main/scala/zio/elasticsearch/ElasticQuery.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
c730d63
to
4a38eb1
Compare
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/FunctionScoreFunction.scala
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
modules/library/src/main/scala/zio/elasticsearch/query/Queries.scala
Outdated
Show resolved
Hide resolved
Chunk( | ||
Some("functions" -> Arr(functionScoreFunctions.map(_.toJson))), | ||
boost.map("boost" -> Num(_)), | ||
boostMode.map(bm => "boost_mode" -> Str(s"${bm.toString.toLowerCase}")), |
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.
boostMode.map(bm => "boost_mode" -> Str(s"${bm.toString.toLowerCase}")), | |
boostMode.map(bm => "boost_mode" -> Str(bm.toString.toLowerCase)), |
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.
Can you also change Str(bm.toString.toLowerCase))
to bm.toString.toLowerCase.toJson
?
Also change this in other places, if any.
faf44e7
to
a268162
Compare
* 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. |
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.
* [[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. |
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.
* [[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. |
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.
* [[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. |
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.
* [[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 |
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.
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. |
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.
* [[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. |
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.
* [[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 |
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.
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. |
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.
* [[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 |
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.
* specifies how the computed scores are combined | |
* specifies how the computed scores are combined. |
* Constructs a type-safe instance of [[zio.elasticsearch.query.FunctionScore]] query with one or multiple | ||
* [[zio.elasticsearch.query.FunctionScoreFunction]] |
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.
* 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 |
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.
* 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]] |
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.
* [[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 |
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.
* 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 |
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.
* 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 |
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:
* the [[scala.Int]] value for `minChildren` parameter | |
* the whole number value for `minChildren` parameter |
No description provided.