Couchbase给出了badarg错误

Couchbase给出了badarg错误,couchbase,couchbase-view,Couchbase,Couchbase View,我创建了简单的couchbase空间视图来获取报告列表,但它给出了{error:“error”,reason:“badarg”}error 以下是我的看法:- function (doc, meta) { if (doc.type == "report" && doc.location && doc.location.type && doc.location.coordinates) { if(doc.location

我创建了简单的couchbase空间视图来获取报告列表,但它给出了
{error:“error”,reason:“badarg”}
error

以下是我的看法:-

function (doc, meta) {
    if (doc.type == "report" && doc.location && doc.location.type && doc.location.coordinates) {

          if(doc.location.type=='Point'){ 
             emit(doc.location, {
               summary:doc.summary
              });
          }
    }
}

为什么会出现此badarg错误,相同的视图在不同的文档上工作。类型

我在空存储桶上使用了您的视图,并使用视图UI页面上的示例查询对其进行了测试:

_design/dev_test/_spatial/test?stale=false&connection_timeout=60000&limit=10&skip=0
在一个空桶上,我得到了一个成功但没有结果的结果,这是意料之中的。一旦我添加了上面的示例文档,我就会得到相同的错误:

    {error: "error", reason: "badarg"}
在对视图和文档进行了一些缩减之后,我发现对于这个特定的文档,它失败了,因为在位置字段(doc.location.coordinates)的纬度和经度坐标周围有双引号。如果要将位置字段作为关键点的几何图形传入,则它们必须是无引号的数字。有关空间视图的更多信息,请参见:

理想情况下,您可以通过修复bucket中的文档来解决问题。无论创建位置字段的是什么,都是在坐标需要浮动时将其作为字符串放入。如果这是不可能的,那么您可以尝试以下类似的方法在视图中进行转换,至少这应该证明字符串坐标是问题的根本原因:

function (doc, meta) {
  if (doc.type == "report" && doc.location && doc.location.type && doc.location.coordinates) {
    if(doc.location.type=='Point'){ 
      for(var i=0; i<doc.location.coordinates.length; i++){
        doc.location.coordinates[i] = parseFloat(doc.location.coordinates[i]); 
      }
      emit(doc.location, {summary:doc.summary});
    }
  }
}
函数(文档、元){
if(doc.type==“report”&&doc.location&&doc.location.type&&doc.location.coordinates){
如果(doc.location.type=='Point'){

对于(var i=0;我在UI中运行它时是否工作?不,它在UI中不工作您通过UI得到了什么错误?{error:“error”,reason:“badarg”}你可以发布一个示例文档吗?在视图中有没有任何方法可以处理这个问题,比如只检查它是字符串还是数字,视图只是javascript,因此你可以测试doc.location.coordinates中的值,如果需要,转换为双倍,然后将其用作键的几何体。你有任何这样的示例吗?请检查我发布的编辑很明显,像我所说的理想解决方案是修复文档生成。当我在视图中使用上面的for循环时,它会给出{error:“error”,reason:“function_子句”}错误