Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JuliaIlic
Copy link

No description provided.

@JuliaIlic JuliaIlic force-pushed the QueryStringQuery-Branch branch from 4b0456e to 653706e Compare June 13, 2025 08:20
test("queryStringQuery"){
val query = range("testField")
val queryNoFields = queryStringQuery("test")
val queryWithFields = queryStringQuery("test").fields("stringField1", "stringField2")
Copy link
Member

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)

},
Copy link
Member

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.

Copy link
Member

@drmarjanovic drmarjanovic left a 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

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.

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

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.

Copy link
Member

@drmarjanovic drmarjanovic left a 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] =
Copy link
Member

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] =
Copy link
Member

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(_))))
Copy link
Member

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?

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