Closed singhvikram704 closed 8 years ago
Refer to Aggregation documentation section
In your case, you need to add the following metadata property to the collection products and you can then get the aggregated data at URI /db/products/_aggrs/myaggr (not the uri property)
"aggrs": [{
"type": "pipeline",
"uri": "myaggr",
"stages": [ {"_$group": {"_id": "$Quantity"} } ]
}]
Hi,
I can use aggregation through restheart successfully.
Thank You very much for Your support.
But in a particular case, when I have to use Match for inside the document or after the unwind. I am getting invalid BSON field name.
For example:
------->>>>>>>
[ {"$unwind": "$abc_Ids"},{ "$match" : { "abc_Ids.abcId"
: "
[ {"_$unwind": "$abcIds"},{ "$match" : { "abcIds.abcId"
: {"$var": "
I am getting error as ------------>>>>>>>>>>>>>>> "http status code": 500, "http status description": "Internal Server Error", "message": "Error handling the request", "_embedded": { "rh:exception": [ { "exception": "java.lang.IllegalArgumentException", "exception message": "Invalid BSON field name abc_Ids.abcId", "stack trace": [ "java.lang.IllegalArgumentException: Invalid BSON field name abc_Ids.abcId", " at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494)", <<<<<<<<<<<<<<<<<<<<<<<---------------------------------------------- Can you guide in this regard. Thanks. Regards, hemraj
editted above content: ---------->>>>>>>>>> as will be used as======>
[ {"_$unwind": "$abcIds"},{ "$match" : { "abcIds.abcId"
: {"$var": "
as you can read in the documentation the aggregation operator must be prefixed with _
this is because in mongodb fields names cannot start with _
for example, to use $unwind you have to actually pass _$unwind in the aggregation definition
I am already using in that way. For the same I again edited the query. But somehow they are being converted to the present view. I am using $match as $match and "$unwind" as $unwind. though I am getting the problem which I have asked for.
Can you pease past the full json you used to create the aggregation?
Just in case since I had this issue in the past: are you using a command line tool in a terminal where $xxx is interpreted as an environment variable?
In case escape it \$xxx
I have collection:
{ "_id" : ObjectId("56696db1429cbd907085cb08"), "attributes" : [ { "_id" : "5666cec9e4b0834319eac761", "name" : "Quantity", "value" : "1kg" }, "status" : "Active", "type" : "single" }
How i use aggregation in restheart like query:
db.products.aggregate({$group : { _id : "$Quantity"}})
Need help regarding this...
Thanx in advance