From edbf5e7f95010441105cb8cb122b022a829ca3c9 Mon Sep 17 00:00:00 2001 From: Matt Hicks Date: Tue, 31 Dec 2024 13:33:50 -0600 Subject: [PATCH] Fixed bug in Query.stream.distance --- core/src/main/scala/lightdb/Query.scala | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/core/src/main/scala/lightdb/Query.scala b/core/src/main/scala/lightdb/Query.scala index 8fa285d8..e0e79232 100644 --- a/core/src/main/scala/lightdb/Query.scala +++ b/core/src/main/scala/lightdb/Query.scala @@ -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)