这是我试图运行的查询:
{ ownerId: 14,
'$or':
[ { '$or':
[ { '$and':
[ { provider: 'INSTAGRAM' },
{ tags:
{ '$or':
[ { '$in': [ 'skyhotel' ] },
{ '$or': [ { '$all': ["skyhotel","excellent"] } ] } ] } } ] },
{ '$and':
[ { provider: 'VKONTAKTE' },
{ tags:
{ '$or':
[ { '$in': [ 'skyhotel' ] },
{ '$or': [ { '$all': ["skyhotel","excellent"] } ] } ] } } ] } ] },
{ '$or':
[ { '$and':
[ { provider: 'INSTAGRAM' },
{ authorLogin: { '$in': [ 'valera92', 'petyan' ] } } ] },
{ '$and':
[ { provider: 'VKONTAKTE' },
{ authorLogin: { '$in': [ 'valera92' ] } } ] } ] },
{ '$or':
[ { '$and':
[ { provider: 'INSTAGRAM' },
{ locationId: { '$in': [ '32454234' ] } } ] } ] },
{ '$or':
[ { '$and':
[ { provider: 'INSTAGRAM' },
{ location: { '$or': [ { '$geoWithin': { '$centerSphere': [ [ '56.829782', '60.593162' ], 0.000012629451881788331 ] } } ] } } ] } ] } ] }

根据mongo标准,它似乎是畸形的。我得到的错误是:
Can't canonicalize query: BadValue unknown operator: $or
我可以通过哪种方式重新格式化此查询?
编辑:文档示例
{
"_id" : ObjectId("570362332ee1a7ab1ecb9899"),
"proextid" : "INSTAGRAM_fdfsfsdfsdfwefwef2r3232",
"updatedAt" : ISODate("2016-04-05T06:58:59.683Z"),
"createdAt" : ISODate("2016-04-05T06:58:59.683Z"),
"ownerId" : 7,
"authorId" : "390599885",
"authorName" : "name",
"authorLogin" : "login",
"authorDetail" : {
"authorPicture" : "url",
"authorLink" : "url"
},
"externalCreatedAt" : ISODate("2015-08-29T22:42:04.000Z"),
"externalId" : "fdsfsdfsdfsdfwer2342342423423r23r",
"detailType" : "PHOTO",
"location" : [
0,
0
],
"locationId" : "",
"locationTitle" : "",
"provider" : "INSTAGRAM",
"detail" : {},
"description" : "hello",
"tags" : [
"ленинградскийпроспект",
"москва",
"архитектура",
"историческоенаследие",
"петровскийдворец"
],
"commentsCount" : 1,
"likesCount" : 40,
"groupName" : "",
"__v" : 0
}

答案 0 :(得分:0)
您的查询可以简化为:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script>
var count=0;
function addRow(tableId)
{
count++;
var element1=document.getElementById(tableId);
var tr=document.createElement("tr");
tr.id="row"+count;
var td1=document.createElement("td");
var td2=document.createElement("td");
var td3=document.createElement("td");
td1.innerHTML="row"+count+" col 1";
td2.innerHTML="row"+count+" col 2";
td3.innerHTML="row"+count+" col 3";
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
element1.appendChild(tr);
alert('row'+count);
}
function removeRow(tableId)
{
var element1=document.getElementById(tableId);
var row=document.getElementById('row'+count);
alert('row'+count);
element1.removeChild(row);
count--;
}
</script>
</head>
<body>
<h1>Hello World!</h1>
<a href="javascript:addRow('table')">Add Row</a><a href="javascript:removeRow('table')" >Remove</a>
<table id="table" border='1'>
</table>
</body>
</html>
现在这可能不是您正在寻找的。但是根据你提出的问题以及你提供的信息,这是我能给出的最佳建议。