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 prefix query #258

Merged
merged 6 commits into from
Jun 24, 2023

Conversation

petarcurcin
Copy link
Contributor

No description provided.

* @param field
* the type-safe field for which query is specified for
* @param value
* the value that will be used for the query, represented by an instance of type `A`
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 value that will be used for the query, represented by an instance of type `A`
* the text value that will be used for the query

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 replace this for term method also?

* @param field
* the field for which query is specified for
* @param value
* the value that will be used for the query, represented by an instance of type `A`
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.

caseInsensitive: Option[Boolean]
) extends PrefixQuery[S] { self =>

override def caseInsensitive(value: Boolean): PrefixQuery[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 omit override?

override def caseInsensitive(value: Boolean): PrefixQuery[S] =
self.copy(caseInsensitive = Some(value))

override private[elasticsearch] def toJson(fieldPath: Option[String]): Json = {
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.

test("prefix") {
val query = prefix(TestDocument.stringField, "test")
val queryWithCaseInsensitive = prefix(TestDocument.stringField, "test").caseInsensitiveTrue
val queryWithAllParams = prefix(TestDocument.stringField, "test").caseInsensitiveFalse
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have only one parameter, so queryWithAllParams is same as queryWithCaseInsensitive.

markaya
markaya previously approved these changes Jun 24, 2023
title: "Prefix Query"
---

The `Prefix` query returns documents that contain a specific prefix in a provided field.
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 `Prefix` query returns documents that contain a specific prefix in a provided field.
The `Prefix` query returns documents that contain a specific prefix in the provided field.

dbulaja98
dbulaja98 previously approved these changes Jun 24, 2023
@@ -2531,6 +2531,36 @@ object ElasticQuerySpec extends ZIOSpecDefault {
assert(queryWithScoreMode.toJson(fieldPath = None))(equalTo(expectedWithScoreMode.toJson)) &&
assert(queryWithAllParams.toJson(fieldPath = None))(equalTo(expectedWithAllParams.toJson))
},
test("prefix") {
Copy link
Member

Choose a reason for hiding this comment

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

Please provide "prefix" tests in "constructing" part as well.

@drmarjanovic drmarjanovic merged commit 0ac0d9a into lambdaworks:main Jun 24, 2023
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.

4 participants