简体   繁体   English

如何创建聚合查询以将mongo集合转储到solr中

[英]How to create aggregate query to dump mongo collection into solr

I created a connection to dump a mongo collection into solr, however, I was wondering if there is any way I can create a query passing an aggregate. 我创建了一个将mongo集合转储到solr中的连接,但是,我想知道是否有任何方法可以创建一个传递聚合的查询。 Ex: 例如:

In my data-config.xml 在我的data-config.xml中

<entity
        processor = "MongoEntityProcessor"
         query = "{total: {$ gte: 0}}"
         collection = "order"
         datasource = "test_development"
         transformer = "MongoMapperTransformer"
         name = "test">

Could I do that? 我可以那样做吗?

<entity
         processor = "MongoEntityProcessor"
         query = "aggregate([{$ project: {_id: 1, total: 1}}])"
         collection = "order"
         datasource = "test_development"
         transformer = "MongoMapperTransformer"
         name = "test">

I and my Technical leader made a fork of a library in github that used only the find function of mongo, we adapted it to be able to put aggregation. 我和我的技术负责人在github中创建了一个库的分支,该库仅使用mongo的find函数,我们对其进行了调整以能够进行聚合。

Follow GitHub with the library and documentation: https://github.com/GuilhermeViterboGalvao/solrMongoDBDataImporter 跟随GitHub的库和文档: https : //github.com/GuilhermeViterboGalvao/solrMongoDBDataImporter

Simple Example: 简单的例子:

<entity  
        processor="MongoDBEntityProcessor"        
        collection="myCollection"
        aggregationQuery="[ { '$project' :{ totalTime: 1, token: 1, statusCode: 1, requestId: 1, date: 1, month: { $month: '$date' }, day: { $dayOfMonth: '$date' }, hour: { $hour: '$date' } } } ]"
        datasource="MyMongoDBDataSourceName-service_development"
        transformer="ObjectIdToLongTransformer" 
        name="myEntityOfCollectionXXX">

You Put de aggregation query in tag "aggregationQuery" and execute data-import in solr cloud 您将聚合查询放入标签“ aggregationQuery”中,并在solr云中执行数据导入

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

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