简体   繁体   English

restheart 2 - 聚合错误

[英]restheart 2 - Aggregation error

We have an aggregation operation that worked in restheart 1.1.0 but now it doesn't in 2.0.2. 我们有一个在restheart 1.1.0中工作的聚合操作,但现在它不在2.0.2中。 We have been using variables in the aggregation operation in order to handle dynamic code generation. 我们一直在聚合操作中使用变量来处理动态代码生成。 Below is a simple example. 下面是一个简单的例子。 Is there a workaround for this issue? 这个问题有解决方法吗?

Here is the aggregation operation: 这是聚合操作:

 {
      "type" : "pipeline", 
      "uri" : "agg_companies", 
      "stages" : [
          {
              "_$match" : {
                  "_$var" : "filter_query"
              }
          }, 
          {
              "_$group" : {
                  "_id" : "$organization._id", 
                  "name" : {
                      "_$first" : "$organization.name"
                  }
              }
          }, 
          {
              "_$sort" : {
                  "name" : NumberInt(1)
              }
          }
      ]
  }

I'm making a request to the aggregation using node with the following: 我正在使用以下节点向聚合发出请求:

This works: 这有效:

var avars = {filter_query: {travelerLastName: "Brewer"}};

This fails: 这失败了:

var avars = {filter_query: {travelerLastName: {$and: ["Brewer"]}}};

Error: 错误:

{ "_links" : { "self" : { "href" : "/foresiteamo/flight/_aggrs/agg_companies2"}} , "http status code" : 400 , "http status description" : "Bad Request" , "message" : "illegal avars paramenter: {\'filter_query\':{\'travelerLastName\':{\'$and\':[\'Brewer\']}}}" , "_embedded" : { "rh:exception" : [ { "exception" : "java.lang.SecurityException" , "exception message" : "aggregation variables cannot include operators"}]}}

RESTHeart does not allow the avars to include operators (any key that starts with $). RESTHeart不允许avars包含运算符(任何以$开头的键)。

this is by design to avoid the client to inject logic into the aggregation and eventually modifying it. 这是为了避免客户端将逻辑注入聚合并最终修改它。

Think about the $lookup operator that might be used to snoop restricted data... 想想可能用于监听受限数据的$ lookup运算符......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM