MarkLogic Optic javaScript 地理空间差异

MarkLogic Optic javaScript Geospatial Difference

我想使用 MarkLogic Optic 减少所选项目与某个点的距离。

我有 table 数据和经纬度

const geoData = op.fromView("namespace","coordinate");
geoData.where(op.le(distance(-28.13,153.4,geoData.col(lat),geoData(long)),100))

距离函数我已经编写并利用 geo.distance(cts.point(lat,long),cts.point(lat,long)) 但是 geoData.col( "lat") 传递一个对象,该对象描述列的全名 space 而不是值。

op.schemaCol('namespace', 'coordinate', 'long')

我怀疑我需要做一个 map/reduce 函数,但 MarkLogic 文档给出了几乎无用的正常简单示例。

我将不胜感激。

FURTHER INFORMATION I have mostly solved most of this problem except that some column have null values. The data is sparse and not all rows have a long lat.

因此,当 cts.points 在 where 语句中运行并且传递了两个空值时,它会引发异常。

当数据列为空时,如何合并或阻止 cts.point 的执行?我不想减少数据集,因为仍然需要返回空值记录,它们将只有一个空距离。

如果可能,最好通过将约束 cts.query() 传递给 where() 来进行过滤。

约束查询匹配索引文档并将行集过滤为 TDE 从这些文档投影的行,然后再从索引中检索过滤的行。

如果纬度和经度列各自是索引文档中不同的 JSON 属性或 XML 元素,则可以使用类似于此处总结的技术来表达距离约束:

http://docs.marklogic.com/guide/search-dev/geospatial#id_42017

一般来说,最好使用 map/reduce SJS 函数对过滤后的结果集进行后处理,因为必须将行检索到 enode 才能在 SJS 中进行处理。

希望对您有所帮助,