Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何获取spring数据mongodb的趋势?_Java_Mongodb_Spring Data Mongodb - Fatal编程技术网

Java 如何获取spring数据mongodb的趋势?

Java 如何获取spring数据mongodb的趋势?,java,mongodb,spring-data-mongodb,Java,Mongodb,Spring Data Mongodb,参考此链接,我们使用的是spring数据mongodb,我们希望计算趋势和总销售额。我们现在有两个查询来获取趋势和总销售额,有没有有效的方法可以做到这一点?请帮忙 样本数据: {"2000-01-01", 1000, "$"} {"2000-01-01", 1000, "$"} {"2000-01-01", 1000, "$"} {"2001-02-01", 2000, "$"} {"2001-02-01", 2000, "$"} {"2001-02-01", 2000, "$"}

参考此链接,我们使用的是spring数据mongodb,我们希望计算趋势和总销售额。我们现在有两个查询来获取趋势和总销售额,有没有有效的方法可以做到这一点?请帮忙

样本数据:

 {"2000-01-01", 1000, "$"}
 {"2000-01-01", 1000, "$"}
 {"2000-01-01", 1000, "$"}
 {"2001-02-01", 2000, "$"}
 {"2001-02-01", 2000, "$"}
 {"2001-02-01", 2000, "$"}
 {"2002-03-01", 3000, "$"}
 {"2002-03-01", 3000, "$"}
 {"2002-03-01", 3000, "$"}
 {"2003-04-01", 4000, "$"}  
 {"2003-04-01", 4000, "$"} 
 {"2003-04-01", 4000, "$"}
例如,我们在查询中计算从“2003-01-01”(开始日期)到“2004-01-01”(结束日期)期间的总销售额,结果是:$12000。 我们通过另一个查询“2002-01-01”(开始日期)到“2003-01-01”(上一个查询的开始日期)计算的趋势

在spring数据mongodb中,是否可以编写一个高效的查询来计算总销售额和总趋势? 我们尝试了以下方法:

   ** by concurrently running the two tasks (one of calculation gross sales and other of calculating trends) by threads and it seems forking thread from the java web application can be disastrous

 ** by using map reduce program in spring-data-mongodb, but of NO use, because we were unable to get the query for pre-dated date to run using map reduce.
请帮助我了解使用SpringDataMongoDB同时计算趋势和总销售额的其他更好的选择。 当做 克里斯

  subtract the previous result $12000 - $9000 (current result) = $3000 trends.
   ** by concurrently running the two tasks (one of calculation gross sales and other of calculating trends) by threads and it seems forking thread from the java web application can be disastrous

 ** by using map reduce program in spring-data-mongodb, but of NO use, because we were unable to get the query for pre-dated date to run using map reduce.