Hello guys,
I've been trying to execute some native map reduce against Monto using Hibernate, but I'm experiencing some difficulties :) what I tried so far :
I tried this query :
Code:
"{ query: { db.article.mapReduce(function() {var key = this.instrument_code;emit(key, this);},function(key, values) {values.sort(function(valueA, valueB){if(valueA.display_datetime < valueB.display_datetime){return 1;}else if(valueA.display_datetime == valueB.display_datetime){return 0;}else{return -1;}}); return values[0] }, { query: { 'instrument_code': { $in: ['EUR', 'JPY', 'GBP', 'DJI', 'CL1', 'GOLDS'] }, 'analysis_type': 'TA' }, out: 'articles'}).find() } }"
and this one
Code:
"db.article.mapReduce(function() {var key = this.instrument_code;emit(key, this);},function(key, values) {values.sort(function(valueA, valueB){if(valueA.display_datetime < valueB.display_datetime){return 1;}else if(valueA.display_datetime == valueB.display_datetime){return 0;}else{return -1;}}); return values[0] }, { query: { 'instrument_code': { $in: ['EUR', 'JPY', 'GBP', 'DJI', 'CL1', 'GOLDS'] }, 'analysis_type': 'TA' }, out: 'articles'}).find()"
both, as native query
Code:
em.createNativeQuery(queryString, Article.class)
but looks like I'm doing something wrong here, does anyone have a hint?
Thank you!!