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 matchBooleanPrefix query #304

Merged

Conversation

milicns
Copy link
Contributor

@milicns milicns commented Aug 15, 2023

Part of #91

@@ -0,0 +1,26 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please show using of miniumum_should_match parameter in doc.

@@ -415,6 +415,44 @@ object ElasticQuery {
final def matches[A: ElasticPrimitive](field: String, value: A): MatchQuery[Any] =
Match(field = field, value = value)

/**
* Constructs a type-safe instance of [[zio.elasticsearch.query.MatchBooleanPrefixQuery]] using the specified
* parameters. [[zio.elasticsearch.query.MatchBooleanPrefixQuery]] analyzes its input and constructs a `bool` query
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make bool query a reference.

* @tparam S
* document for which field query is executed
* @tparam A
* the type of value to be matched. A JSON decoder must be in scope for this type
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 type of value to be matched. A JSON decoder must be in scope for this type
* the type of value to be matched. A JSON decoder must be provided in the scope for this type


/**
* Constructs an instance of [[zio.elasticsearch.query.MatchBooleanPrefixQuery]] using the specified parameters.
* [[zio.elasticsearch.query.MatchBooleanPrefixQuery]] analyzes its input and constructs a `bool` query from the
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.

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

Comment on lines 576 to 577
) extends MatchBooleanPrefixQuery[S] { self =>
def minimumShouldMatch(value: Int): MatchBooleanPrefixQuery[S] =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put an empty line between.

@@ -873,6 +873,53 @@ object ElasticQuerySpec extends ZIOSpecDefault {
equalTo(Match[TestDocument, Double](field = "doubleField", value = 3.14))
)
},
test("matchBooleanPrefix") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add one test for query with suffix (for creating json too).

@@ -917,6 +917,48 @@ object HttpExecutorSpec extends IntegrationSpec {
Executor.execute(ElasticRequest.createIndex(firstSearchIndex)),
Executor.execute(ElasticRequest.deleteIndex(firstSearchIndex)).orDie
),
test("search for a document using a match boolean prefix query") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Write just one it-test for this query. There is no need to check minimumShouldMatch only.

@milicns milicns requested a review from dbulaja98 August 22, 2023 07:31
```

You can find more information about `MatchBooleanPrefix` query [here](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-match-bool-prefix-query.html).

Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary new line.

@@ -873,6 +873,57 @@ object ElasticQuerySpec extends ZIOSpecDefault {
equalTo(Match[TestDocument, Double](field = "doubleField", value = 3.14))
)
},
test("matchBooleanPrefix") {
Copy link
Member

Choose a reason for hiding this comment

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

Move this between matchAll and matches.

@@ -2427,6 +2478,76 @@ object ElasticQuerySpec extends ZIOSpecDefault {
assert(queryTsInt.toJson(fieldPath = None))(equalTo(expectedTsInt.toJson)) &&
assert(queryTsString.toJson(fieldPath = None))(equalTo(expectedTsString.toJson))
},
test("matchBooleanPrefix") {
Copy link
Member

Choose a reason for hiding this comment

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

Move this between matchAll and matches.

@milicns milicns requested a review from drmarjanovic August 23, 2023 08:25
Copy link
Collaborator

@dbulaja98 dbulaja98 left a comment

Choose a reason for hiding this comment

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

Nice job!

@dbulaja98 dbulaja98 merged commit 59e58bd into lambdaworks:main Aug 23, 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.

3 participants