Skip to content

Commit

Permalink
Minor fix to Lucene's creation of geo fields from arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Dec 6, 2024
1 parent 7695076 commit 720a045
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lucene/src/main/scala/lightdb/lucene/LuceneStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ class LuceneStore[Doc <: Document[Doc], Model <: DocumentModel[Doc]](name: Strin

private def createGeoFields(field: Field[Doc, _],
json: Json,
add: LuceneField => Unit): Unit = {
add: LuceneField => Unit): Unit = if (json.isArr) {
json.asVector.foreach { json =>
createGeoFields(field, json, add)
}
} else {
field.className match {
case Some("lightdb.spatial.Geo.Point") =>
val p = json.as[Geo.Point]
Expand Down Expand Up @@ -156,7 +160,11 @@ class LuceneStore[Doc <: Document[Doc], Model <: DocumentModel[Doc]](name: Strin
case _ =>
def addJson(json: Json, d: DefType): Unit = {
if (field.isSpatial) {
if (json != Null) createGeoFields(field, json, add)
if (json != Null) try {
createGeoFields(field, json, add)
} catch {
case t: Throwable => throw new RuntimeException(s"Failure to populate geo field '$name.${field.name}' for $doc (json: $json)", t)
}
} else {
d match {
case DefType.Str => json match {
Expand Down

0 comments on commit 720a045

Please sign in to comment.