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 Boosting query #364

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

vanjaftn
Copy link
Contributor

@vanjaftn vanjaftn commented Nov 14, 2023

Part of #64

@vanjaftn vanjaftn changed the title (dsl): Support Boosting query (dsl): Support Boosting query Nov 14, 2023
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.
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 `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] {
Copy link
Collaborator

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.
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 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](
Copy link
Collaborator

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.
Copy link
Collaborator

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.
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 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](
Copy link
Collaborator

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]
Copy link
Collaborator

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") {
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
test("boost") {
test("boosting") {

@@ -2146,6 +2168,32 @@ object ElasticQuerySpec extends ZIOSpecDefault {
assert(queryWithAllParams.toJson(fieldPath = None))(equalTo(expectedWithAllParams.toJson))
}
),
test("boost") {
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
test("boost") {
test("boosting") {

Comment on lines 29 to 30
* Constructs a type-safe instance of [[zio.elasticsearch.query.BoostingQuery]] with queries that must satisfy the
* criteria using the specified parameters.
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.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.

Copy link
Collaborator

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.

Comment on lines 51 to 52
* Constructs an instance of [[zio.elasticsearch.query.BoostingQuery]] with queries that must satisfy the criteria
* using the specified parameters.
Copy link
Collaborator

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
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
* 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
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
* 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.

@dbulaja98 dbulaja98 merged commit 4cf07e7 into lambdaworks:main Nov 20, 2023
13 checks passed
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.

None yet

2 participants