Skip to content

Commit

Permalink
Fixed bug in Query.stream.distance
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Dec 31, 2024
1 parent a3f32b1 commit edbf5e7
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions core/src/main/scala/lightdb/Query.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,8 @@ case class Query[Doc <: Document[Doc], Model <: DocumentModel[Doc]](model: Model
from: Geo.Point,
sort: Boolean = true,
radius: Option[Distance] = None)
(implicit transaction: Transaction[Doc]): rapid.Stream[DistanceAndDoc[Doc]] = {
val field = f(model)
var q = Query.this
if (sort) {
q = q.clearSort.sort(Sort.ByDistance(field, from))
}
radius.foreach { r =>
q = q.filter(_ => field.distance(from, r))
}
rapid.Stream.force(q.distanceSearch(field, from, sort, radius).map(_.stream))
}
(implicit transaction: Transaction[Doc]): rapid.Stream[DistanceAndDoc[Doc]] = rapid.Stream
.force(search.distance(f, from, sort, radius).map(_.stream))
}

def toList(implicit transaction: Transaction[Doc]): Task[List[Doc]] = search.docs.flatMap(_.list)
Expand Down

0 comments on commit edbf5e7

Please sign in to comment.