-
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 Boosting
query
#364
(dsl): Support Boosting
query
#364
Conversation
title: "Boosting Query" | ||
--- | ||
|
||
The `Boosting` query returns documents that match the positive query. Among those documents, the ones that also match the negative query get their relevance score lowered by multiplying it by the negative boosting factor. |
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 `Boosting` query returns documents that match the positive query. Among those documents, the ones that also match the negative query get their relevance score lowered by multiplying it by the negative boosting factor. | |
The `Boosting` query returns documents that match the query marked as `positive` while reducing the relevance score of documents that also match a query which is marked as `negative` query. |
@@ -39,6 +39,10 @@ object ElasticPrimitive { | |||
def toJson(value: Double): Json = Num(value) | |||
} | |||
|
|||
implicit object ElasticFloat extends ElasticPrimitive[Float] { |
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.
Just keep in mind when you start with rebase later that you have already added this in other PR.
* criteria using the specified parameters. | ||
* | ||
* @param negativeBoost | ||
* the query that decreases the relevance score of matching documents. |
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 query that decreases the relevance score of matching documents. | |
* the number between 0 and 1.0 used to decrease the relevance score of documents matching the negative query |
* @return | ||
* an instance of [[zio.elasticsearch.query.BoostQuery]] that represents the boost query to be performed. | ||
*/ | ||
final def boost[S: Schema]( |
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 rename both methods to boosting
?
* the specified parameters. | ||
* | ||
* @param negativeBoost | ||
* the query that decreases the relevance score of matching documents. |
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.
Same here.
* @param negativeQuery | ||
* the query that decreases the relevance score of matching documents. | ||
* @param positiveQuery | ||
* the query that must be satisfied. |
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 query that must be satisfied. | |
* the query that must be satisfied |
@@ -184,6 +184,24 @@ private[elasticsearch] final case class Bool[S]( | |||
} | |||
} | |||
|
|||
sealed trait BoostQuery[S] extends ElasticQuery[S] | |||
|
|||
private[elasticsearch] final case class Boost[S]( |
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 rename this to Boosting[S]
?
@@ -184,6 +184,24 @@ private[elasticsearch] final case class Bool[S]( | |||
} | |||
} | |||
|
|||
sealed trait BoostQuery[S] extends ElasticQuery[S] |
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 rename this to BoostingQuery[S]
?
@@ -334,6 +334,28 @@ object ElasticQuerySpec extends ZIOSpecDefault { | |||
) | |||
} | |||
), | |||
test("boost") { |
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.
test("boost") { | |
test("boosting") { |
@@ -2146,6 +2168,32 @@ object ElasticQuerySpec extends ZIOSpecDefault { | |||
assert(queryWithAllParams.toJson(fieldPath = None))(equalTo(expectedWithAllParams.toJson)) | |||
} | |||
), | |||
test("boost") { |
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.
test("boost") { | |
test("boosting") { |
8704dc9
to
32320e9
Compare
* Constructs a type-safe instance of [[zio.elasticsearch.query.BoostingQuery]] with queries that must satisfy the | ||
* criteria using the specified parameters. |
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.BoostingQuery]] with queries that must satisfy the | |
* criteria using the specified parameters. | |
* Constructs a type-safe instance of [[zio.elasticsearch.query.BoostingQuery]] using the specified parameters. |
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.
And maybe add something like text in doc:
Boosting
query returns documents that match the query marked as positive
while reducing the relevance score of documents that also match a query which is marked as negative
query.
* Constructs an instance of [[zio.elasticsearch.query.BoostingQuery]] with queries that must satisfy the criteria | ||
* using the specified parameters. |
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.
Same here.
* @param positiveQuery | ||
* the query that must be satisfied | ||
* @return | ||
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query 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.
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query to be performed | |
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query to be performed. |
* @tparam S | ||
* document for which field query is executed. An implicit `Schema` instance must be in scope | ||
* @return | ||
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query 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.
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query to be performed | |
* an instance of [[zio.elasticsearch.query.BoostingQuery]] that represents the boost query to be performed. |
66f571c
to
04a7850
Compare
Part of #64