Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See if the following is in line with what you want to accomplish:</p> <pre><code>db.bbticks.aggregate( [ { $match: { time: { $gte: ISODate("2013-08-01") } } }, { $group: { _id: "$time", count: {$sum: 1}, tickers: { $push: { "ticker": "$ticker" , "close": "$close" } } } } , { $match: { count: { $gt: 1 } } } ] ) </code></pre> <p>-- break --</p> <p>For the map-reduce, you could try the following (not very elegant, I think there are better ways but just some ideas to get you started). Also, as this will be a time series that grows, chances are you might want to use an incremental map-reduce (<a href="http://docs.mongodb.org/manual/tutorial/perform-incremental-map-reduce/" rel="nofollow">http://docs.mongodb.org/manual/tutorial/perform-incremental-map-reduce/</a>). But the below can give you some ideas (like I said, it is ugly --- and it might be better to perform a second map-reduce operation rather than my last find statement, but up to you).</p> <pre><code>var mapFunction = function() { var key = this.time var value = { tickers: [ { ticker: this.ticker, close: this.close } ] }; emit( key, value ); }; var reduceFunction = function(keyObject, valuesArray) { var reducedValue = { tickers: [] }; for (var idx = 0; idx &lt; valuesArray.length; idx++) { reducedValue.tickers.push( valuesArray[idx].tickers[0] ) } return reducedValue; }; db.bbticks.mapReduce( mapFunction, reduceFunction, { out: "mr_interim_results", sort: { time: 1 }, query: { time: {$gte: ISODate("2013-08-01") } }, } ) db.mr_interim_results.find( { 'value.tickers': { $not: { $size: 1 } } } ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload