From e2357eac3e1daad76c1d2cef9f324e317027acf6 Mon Sep 17 00:00:00 2001 From: Josh Baker Date: Thu, 3 Aug 2017 04:01:07 -0700 Subject: [PATCH] empty results when key not found, #207 --- controller/search.go | 59 ++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/controller/search.go b/controller/search.go index 7e6b228a..efc2bfed 100644 --- a/controller/search.go +++ b/controller/search.go @@ -400,40 +400,39 @@ func (c *Controller) cmdWithinOrIntersects(cmd string, msg *server.Message) (res if err != nil { return "", err } - if sw.col == nil { - return "", errKeyNotFound - } if msg.OutputType == server.JSON { wr.WriteString(`{"ok":true`) } sw.writeHead() - minZ, maxZ := zMinMaxFromWheres(s.wheres) - if cmd == "within" { - sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, - func(id string, o geojson.Object, fields []float64) bool { - if c.hasExpired(s.key, id) { - return true - } - return sw.writeObject(ScanWriterParams{ - id: id, - o: o, - fields: fields, - }) - }, - ) - } else if cmd == "intersects" { - sw.col.Intersects(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, - func(id string, o geojson.Object, fields []float64) bool { - if c.hasExpired(s.key, id) { - return true - } - return sw.writeObject(ScanWriterParams{ - id: id, - o: o, - fields: fields, - }) - }, - ) + if sw.col != nil { + minZ, maxZ := zMinMaxFromWheres(s.wheres) + if cmd == "within" { + sw.col.Within(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, + func(id string, o geojson.Object, fields []float64) bool { + if c.hasExpired(s.key, id) { + return true + } + return sw.writeObject(ScanWriterParams{ + id: id, + o: o, + fields: fields, + }) + }, + ) + } else if cmd == "intersects" { + sw.col.Intersects(s.sparse, s.o, s.minLat, s.minLon, s.maxLat, s.maxLon, minZ, maxZ, + func(id string, o geojson.Object, fields []float64) bool { + if c.hasExpired(s.key, id) { + return true + } + return sw.writeObject(ScanWriterParams{ + id: id, + o: o, + fields: fields, + }) + }, + ) + } } sw.writeFoot() if msg.OutputType == server.JSON {