Limit no. of rows in mongodb input

…衆ロ難τιáo~ 提交于 2019-12-22 08:19:21

问题


How to limit the no. of rows retrieved in mongodb input transformation used in kettle.

I tried in mongodb input query with below queries but none of them are working :

{"$query" : {"$limit" : 10}} or {"$limit" : 10}

Please let me know where i am going wrong.

Thanks, Deepthi


回答1:


There are several query modification operators you can use. Their names are not totally intuitive and don't match the names of functions you would use in the Mongo shell, but they do the same sorts of things.

In your case, you need the $maxScan operator. You could write your query as:

{"$query": {...}, "$maxScan": 10}



回答2:


We have to use aggregation method providing by MongoDB, and here is the link: docs.mongodb.org/manual/applications/aggregation.

In my case, I use this query in MongoDB Input of Kettle, and we also have to choose Query is aggregation pipline.

{$match: {activity_type: " view "}},
{$sort: {activity_target: -1 } },
{$limit: 10}

The following screen shots can help you understand the operations more clear.



来源:https://stackoverflow.com/questions/17272198/limit-no-of-rows-in-mongodb-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!