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

(fix): Resolve minor issues #230

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import sttp.model.StatusCode.{
}
import sttp.model.Uri.QuerySegment
import zio.ZIO.logDebug
import zio.elasticsearch.ElasticPrimitive.ElasticPrimitiveOps
import zio.elasticsearch.ElasticRequest._
import zio.elasticsearch._
import zio.elasticsearch.executor.response.{
Expand All @@ -44,7 +45,7 @@ import zio.elasticsearch.executor.response.{
import zio.elasticsearch.request.{CreationOutcome, DeletionOutcome, UpdateOutcome}
import zio.elasticsearch.result._
import zio.json.ast.Json
import zio.json.ast.Json.{Arr, Obj, Str}
import zio.json.ast.Json.{Arr, Obj}
import zio.json.{DeriveJsonDecoder, JsonDecoder}
import zio.schema.Schema
import zio.stream.{Stream, ZStream}
Expand Down Expand Up @@ -341,7 +342,7 @@ private[elasticsearch] final class HttpExecutor private (esConfig: ElasticConfig
.post(uri"${esConfig.uri}/$Search/$Scroll".withParams((Scroll, config.keepAlive)))
.response(asJson[SearchWithAggregationsResponse])
.contentType(ApplicationJson)
.body(Obj(ScrollId -> Str(scrollId)))
.body(Obj(ScrollId -> scrollId.toJson))
).flatMap { response =>
response.code match {
case HttpOk =>
Expand Down Expand Up @@ -403,32 +404,31 @@ private[elasticsearch] final class HttpExecutor private (esConfig: ElasticConfig
searchAfter: Option[Json]
): Task[(Chunk[Item], Option[(String, Option[Json])])] = {
val pointInTimeJson =
Json.Obj(
"pit" -> Json.Obj(
"id" -> Json.Str(pitId),
KeepAlive -> Json.Str(config.keepAlive)
Obj(
"pit" -> Obj(
"id" -> pitId.toJson,
KeepAlive -> config.keepAlive.toJson
)
)

val sortsJson =
if (r.sortBy.isEmpty) {
Obj("sort" -> Json.Arr(Json.Str(ShardDoc)))
Obj("sort" -> Arr(ShardDoc.toJson))
} else {
Obj("sort" -> Arr(r.sortBy.map(_.toJson)))
}

val searchAfterJson = searchAfter.fold(Obj())(sa => Obj("search_after" -> sa))

sendRequestWithCustomResponse(
baseRequest
.get(uri"${esConfig.uri}/$Search")
.response(asJson[SearchWithAggregationsResponse])
.contentType(ApplicationJson)
.body(
Obj("query" -> r.query.toJson(fieldPath = None)) merge
pointInTimeJson merge
sortsJson merge
pointInTimeJson merge
searchAfterJson
Obj("query" -> r.query.toJson(fieldPath = None)) merge
searchAfter.fold(Obj())(sa => Obj("search_after" -> sa)) merge
config.pageSize.fold(Obj())(ps => Obj("size" -> ps.toJson))
)
).flatMap { response =>
response.code match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ sealed trait DistanceUnit {
}

object DistanceUnit {
case object Centimeter extends DistanceUnit { def symbol: String = "cm" }
case object Feet extends DistanceUnit { def symbol: String = "ft" }
case object Inch extends DistanceUnit { def symbol: String = "in" }
case object Kilometers extends DistanceUnit { def symbol: String = "km" }
case object Mile extends DistanceUnit { def symbol: String = "mi" }
case object Meter extends DistanceUnit { def symbol: String = "m" }
case object Milimeter extends DistanceUnit { def symbol: String = "mm" }
case object NauticalMile extends DistanceUnit { def symbol: String = "nmi" }
case object Yard extends DistanceUnit { def symbol: String = "yd" }
case object Centimeters extends DistanceUnit { def symbol: String = "cm" }
case object Feet extends DistanceUnit { def symbol: String = "ft" }
case object Inches extends DistanceUnit { def symbol: String = "in" }
case object Kilometers extends DistanceUnit { def symbol: String = "km" }
case object Miles extends DistanceUnit { def symbol: String = "mi" }
case object Meters extends DistanceUnit { def symbol: String = "m" }
case object Millimeters extends DistanceUnit { def symbol: String = "mm" }
case object NauticalMiles extends DistanceUnit { def symbol: String = "nmi" }
case object Yards extends DistanceUnit { def symbol: String = "yd" }
}

sealed trait DistanceType {
Expand Down