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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add integration test
  • Loading branch information
LeonaNedeljkovic committed Dec 4, 2023
commit c20d0772bf7026dbaa5de2df5a1c3c285027bc4d
Original file line number Diff line number Diff line change
@@ -2680,6 +2680,41 @@ object HttpExecutorSpec extends IntegrationSpec {
}
} @@ after(Executor.execute(ElasticRequest.deleteIndex(geoDistanceIndex)).orDie)
),
suite("geo-polygon query")(
test("using geo-polygon query") {
checkOnce(genTestDocument) { document =>
val indexDefinition =
"""
|{
| "mappings": {
| "properties": {
| "locationField": {
| "type": "geo_point"
| }
| }
| }
|}
|""".stripMargin

for {
_ <- Executor.execute(ElasticRequest.createIndex(geoPolygonIndex, indexDefinition))
_ <- Executor.execute(ElasticRequest.deleteByQuery(geoPolygonIndex, matchAll))
_ <- Executor.execute(
ElasticRequest.create[TestDocument](geoPolygonIndex, document).refreshTrue
)
r1 <- Executor
.execute(
ElasticRequest.search(
geoPolygonIndex,
ElasticQuery
.geoPolygon("locationField", List("0, 0", "0, 90", "90, 90", "90, 0"))
)
)
.documentAs[TestDocument]
} yield assertTrue(r1 == Chunk(document))
}
} @@ after(Executor.execute(ElasticRequest.deleteIndex(geoPolygonIndex)).orDie)
),
suite("search for documents using FunctionScore query")(
test("using randomScore function") {
checkOnce(genTestDocument, genTestDocument) { (firstDocument, secondDocument) =>
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ trait IntegrationSpec extends ZIOSpecDefault {

val IndexPatternAll: IndexPattern = IndexPattern("_all")

val geoPolygonIndex: IndexName = IndexName("geo-polygon-index")

val prepareElasticsearchIndexForTests: TestAspect[Nothing, Any, Throwable, Any] = beforeAll((for {
_ <- Executor.execute(ElasticRequest.createIndex(index))
_ <- Executor.execute(ElasticRequest.deleteByQuery(index, matchAll).refreshTrue)