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 geoPolygon query #264

Merged

Conversation

LeonaNedeljkovic
Copy link
Contributor

@LeonaNedeljkovic LeonaNedeljkovic commented Jun 24, 2023

Part of #91

@drmarjanovic drmarjanovic changed the title (dsl) Support geopolygon query (dsl): Support geoPolygon query Jun 24, 2023
"geo_polygon" -> Obj(
Chunk(
Some(field -> Obj("points" -> Arr(points.map(Json.Str(_)): _*))),
queryName.map(qn => "_name" -> qn.toJson),
Copy link
Member

Choose a reason for hiding this comment

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

Let's use queryName.map("_name" -> _.toJson).

Chunk(
Some(field -> Obj("points" -> Arr(points.map(Json.Str(_)): _*))),
queryName.map(qn => "_name" -> qn.toJson),
validationMethod.map(vm => "validation_method" -> vm.toString.toJson)
Copy link
Member

Choose a reason for hiding this comment

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

Let's use validationMethod.map("validation_method" -> _.toString.toJson).

)
)
) &&
assert(queryString)(
Copy link
Member

Choose a reason for hiding this comment

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

Should we move this in the row above?

.validationMethod(IgnoreMalformed)
.name("name")

println(queryWithName.toJson(fieldPath = None))
Copy link
Member

Choose a reason for hiding this comment

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

Please remove println.

* field to identify the query
*
* @param value
* the [[String]] value to represent the name 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 [[String]] value to represent the name field
* the text value to represent the name field

validationMethod: Option[ValidationMethod]
) extends GeoPolygonQuery[S] { self =>

def name(value: String): GeoPolygonQuery[S] = self.copy(queryName = Some(value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move self.copy(queryName = Some(value)) to new line.

markaya
markaya previously approved these changes Jun 24, 2023
dbulaja98
dbulaja98 previously approved these changes Jun 24, 2023
@LeonaNedeljkovic LeonaNedeljkovic dismissed stale reviews from dbulaja98 and markaya via b901e6d June 24, 2023 14:46
)
)
.documentAs[TestDocument]
} yield assertTrue(r1 == Chunk(document))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} yield assertTrue(r1 == Chunk(document))
} yield assert(equalTo(Chunk(document)))

geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90")).validationMethod(
IgnoreMalformed
)
val queryWithAllParams = geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val queryWithAllParams = geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90"))
val queryWithAllParams =
geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90"))

drmarjanovic
drmarjanovic previously approved these changes Jun 24, 2023
dbulaja98
dbulaja98 previously approved these changes Jun 28, 2023
@drmarjanovic
Copy link
Member

@LeonaNedeljkovic, are you still working on this? Is there anything that's blocking you?

@LeonaNedeljkovic LeonaNedeljkovic force-pushed the task-support-geopolygon-query branch 2 times, most recently from 410578f to 7856cc4 Compare December 14, 2023 18:45
@LeonaNedeljkovic LeonaNedeljkovic force-pushed the task-support-geopolygon-query branch from 7856cc4 to 39bc4ca Compare December 14, 2023 18:59
* field to identify the query
*
* @param value
* the text value to represent the name 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 text value to represent the name field
* the text value that represents the name field

* the type-safe field for which query is specified for
* @param coordinates
* list of longitudes and latitudes of the desired points written as string (e.g. ["40, 31", "25, 31"]) or geo hash
* (e.g. ["drm3btev3e86", "drm3btev3e87"] )
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
* (e.g. ["drm3btev3e86", "drm3btev3e87"] )
* (e.g. ["drm3btev3e86", "drm3btev3e87"])

* the field for which query is specified for
* @param coordinates
* list of longitudes and latitudes of the desired points written as string (e.g. ["40, 31", "25, 31"]) or geo hash
* (e.g. ["drm3btev3e86", "drm3btev3e87"] )
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
* (e.g. ["drm3btev3e86", "drm3btev3e87"] )
* (e.g. ["drm3btev3e86", "drm3btev3e87"])

* @return
* an instance of [[zio.elasticsearch.query.GeoPolygonQuery]] that represents `geo_polygon` query to be performed.
*/
final def geoPolygon(field: String, coordinates: List[String]): GeoPolygonQuery[Any] =
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 List[String] with Chunk[String]?

* @return
* an instance of [[zio.elasticsearch.query.GeoPolygonQuery]] that represents `geo_polygon` query to be performed.
*/
final def geoPolygon[S](field: Field[S, _], coordinates: List[String]): GeoPolygonQuery[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 replace List[String] with Chunk[String]?


private[elasticsearch] final case class GeoPolygon[S](
field: String,
points: List[String],
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 List[String] with Chunk[String]?

test("geoPolygon") {
val query =
geoPolygon("testField", List("40, -70", "30, -80", "20, -90"))
val queryString =
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
val queryString =
val queryTs =

test("geoPolygon") {
val query =
geoPolygon("testField", List("40, -70", "30, -80", "20, -90"))
val queryString =
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
val queryString =
val queryTs =

|}
|""".stripMargin

val expectedWithString =
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
val expectedWithString =
val expectedTs =

val query: GeoPolygonQuery = geoPolygon(field = Document.location, List("0, 0", "0, 90", "90, 90", "90, 0"))
```


Copy link
Collaborator

Choose a reason for hiding this comment

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

Omit one empty line.

@dbulaja98 dbulaja98 merged commit f1a33dd into lambdaworks:main Dec 21, 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