-
Notifications
You must be signed in to change notification settings - Fork 20
Added QueryStringQuery #648
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
base: main
Are you sure you want to change the base?
Conversation
4b0456e
to
653706e
Compare
modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala
Outdated
Show resolved
Hide resolved
test("queryStringQuery"){ | ||
val query = range("testField") | ||
val queryNoFields = queryStringQuery("test") | ||
val queryWithFields = queryStringQuery("test").fields("stringField1", "stringField2") |
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.
Provide queryWithFields
where fields aren't plain strings.
val queryWithFields = queryStringQuery("test").fields("stringField1", "stringField2") | ||
val queryWithMinShouldMatch = queryNoFields.minimumShouldMatch(2) | ||
|
||
}, |
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.
We are missing an assertion here.
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/ElasticQuery.scala
Outdated
Show resolved
Hide resolved
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.
Also, additionally:
- Please use better PR title
- Link the issue you're resolving in description
- Format your code before pushing it - you can use
sbt prepare
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.
Good first PR.
Just few things:
- You are missing some integrations tests
- You are missing documentation page for this query
* @return | ||
* an instance of [[zio.elasticsearch.query.QueryStringQuery]] that represents the query to be performed. | ||
*/ | ||
final def queryStringQuery[S: Schema](query: String, fields: Field[S, _]*): QueryStringQuery[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.
Since this fields
parameter can be empty list, maybe we shouldn't ask for it here. In other method you don't have it as parameter, so I would do it like this here too.
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
modules/library/src/test/scala/zio/elasticsearch/ElasticQuerySpec.scala
Outdated
Show resolved
Hide resolved
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.
Several things are missing:
- website docs
- integration tests
Besides that, let's rename a method and link to the issue properly.
* @return | ||
* an instance of [[zio.elasticsearch.query.QueryStringQuery]] that represents the query to be performed. | ||
*/ | ||
final def queryStringQuery[S: Schema](query: String, fields: Field[S, _]*): QueryStringQuery[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.
Does it make sense for fields to be empty?
def fields(field: String, fields: String*): QueryStringQuery[S] = | ||
self.copy(fields = Chunk.fromIterable(field +: fields)) | ||
|
||
def fields(fields: Chunk[String]): QueryStringQuery[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.
Do we need this?
|
||
private[elasticsearch] def toJson(fieldPath: Option[String]): Json = { | ||
val fieldsJson = | ||
if (fields.nonEmpty) Some("fields" -> Arr(fields.map(Str(_)))) |
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 we use .map
here?
No description provided.