Indexing CLoudant地理搜索函数
我正在尝试使用cloudant的地理搜索功能 我创建了一个搜索索引,如下所示:Indexing CLoudant地理搜索函数,indexing,cloudant,Indexing,Cloudant,我正在尝试使用cloudant的地理搜索功能 我创建了一个搜索索引,如下所示: { "_id": "_design/locations2", "_rev": "1-ca7f78894c9e6a26539f81322b640b4e", "indexes": { "find1": "function(doc){if(doc.coor
{
"_id": "_design/locations2",
"_rev": "1-ca7f78894c9e6a26539f81322b640b4e",
"indexes": {
"find1": "function(doc){if(doc.coord){index('lat', doc.coord[0], {\"store\":\"yes\"});index('lon', doc.coord[1], {\"store\":\"yes\"})}; }"
}
}
{
"_id": "9b01e808371c049285b1b40d1077c934",
"_rev": "1-770b0d49ef839713003c5f17f81d3fc1",
"type": "location",
"name": "test",
"description": "description",
"coord": [ - 31.936722, 115.754979]
}
我有以下几个文件:
{
"_id": "_design/locations2",
"_rev": "1-ca7f78894c9e6a26539f81322b640b4e",
"indexes": {
"find1": "function(doc){if(doc.coord){index('lat', doc.coord[0], {\"store\":\"yes\"});index('lon', doc.coord[1], {\"store\":\"yes\"})}; }"
}
}
{
"_id": "9b01e808371c049285b1b40d1077c934",
"_rev": "1-770b0d49ef839713003c5f17f81d3fc1",
"type": "location",
"name": "test",
"description": "description",
"coord": [ - 31.936722, 115.754979]
}
那么我的疑问如下:
{
"_id": "_design/locations2",
"_rev": "1-ca7f78894c9e6a26539f81322b640b4e",
"indexes": {
"find1": "function(doc){if(doc.coord){index('lat', doc.coord[0], {\"store\":\"yes\"});index('lon', doc.coord[1], {\"store\":\"yes\"})}; }"
}
}
{
"_id": "9b01e808371c049285b1b40d1077c934",
"_rev": "1-770b0d49ef839713003c5f17f81d3fc1",
"type": "location",
"name": "test",
"description": "description",
"coord": [ - 31.936722, 115.754979]
}
.cloudant.com/epic_test_db/_design/locations2/_search/find1?q=test
我收到这个错误:
{"error":"{case_clause,{<<\"find1\">>,\n <<\"function(doc){if(doc.coord){index('lat', doc.coord[0], {\\\"store\\\":\\\"yes\\\"});index('lon', doc.coord[1], {\\\"store\\\":\\\"yes\\\"})}; }\">>}}","reason":"[{dreyfus_index,design_doc_to_index,2},\n {dreyfus_rpc,call,5},\n {rexi_server,init_p,3}]"}
{“error”:“{case_子句,{,\n}}”,“原因”:“[{dreyfus_索引,design_doc_to_索引,2},\n{dreyfus_rpc,call,5},\n{rexi_服务器,init_p,3}”
知道为什么吗
好的,我找到答案了。我在函数(doc)之前的索引定义中遗漏了索引
好的,我找到答案了。我在函数(doc)之前的索引定义中遗漏了索引