-
Notifications
You must be signed in to change notification settings - Fork 17
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
(dsl): Support geoPolygon
query
#264
Conversation
geoPolygon
query
"geo_polygon" -> Obj( | ||
Chunk( | ||
Some(field -> Obj("points" -> Arr(points.map(Json.Str(_)): _*))), | ||
queryName.map(qn => "_name" -> qn.toJson), |
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.
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) |
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.
Let's use validationMethod.map("validation_method" -> _.toString.toJson)
.
) | ||
) | ||
) && | ||
assert(queryString)( |
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.
Should we move this in the row above?
.validationMethod(IgnoreMalformed) | ||
.name("name") | ||
|
||
println(queryWithName.toJson(fieldPath = None)) |
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.
Please remove println
.
* field to identify the query | ||
* | ||
* @param value | ||
* the [[String]] value to represent the name field |
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.
* 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)) |
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.
Move self.copy(queryName = Some(value))
to new line.
) | ||
) | ||
.documentAs[TestDocument] | ||
} yield assertTrue(r1 == Chunk(document)) |
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.
} 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")) |
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.
val queryWithAllParams = geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90")) | |
val queryWithAllParams = | |
geoPolygon(TestDocument.stringField, List("40, -70", "30, -80", "20, -90")) |
@LeonaNedeljkovic, are you still working on this? Is there anything that's blocking you? |
410578f
410578f
to
7856cc4
Compare
7856cc4
to
39bc4ca
Compare
* field to identify the query | ||
* | ||
* @param value | ||
* the text value to represent the name field |
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.
* 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"] ) |
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.
* (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"] ) |
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.
* (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] = |
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 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] = |
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 you replace List[String]
with Chunk[String]
?
|
||
private[elasticsearch] final case class GeoPolygon[S]( | ||
field: String, | ||
points: List[String], |
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 you replace List[String]
with Chunk[String]
?
test("geoPolygon") { | ||
val query = | ||
geoPolygon("testField", List("40, -70", "30, -80", "20, -90")) | ||
val queryString = |
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.
val queryString = | |
val queryTs = |
test("geoPolygon") { | ||
val query = | ||
geoPolygon("testField", List("40, -70", "30, -80", "20, -90")) | ||
val queryString = |
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.
val queryString = | |
val queryTs = |
|} | ||
|""".stripMargin | ||
|
||
val expectedWithString = |
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.
val expectedWithString = | |
val expectedTs = |
val query: GeoPolygonQuery = geoPolygon(field = Document.location, List("0, 0", "0, 90", "90, 90", "90, 0")) | ||
``` | ||
|
||
|
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.
Omit one empty line.
Part of #91