public class TagSampleTemplate {

    /**
     * 
     */
    public TagSampleTemplate() {
    }

    @Autowired
    private MongoTemplate mongoTemplate;
    
    public ArrayList<DBObject> findByTag(String tag){
        DBCollection collection = mongoTemplate.getCollection("tagSample");
        DBObject query = new BasicDBObject();
        query.put("tag", tag);
        
        DBObject sort = new BasicDBObject();
        sort.put("tagCount", -1);
        DBCursor cursor = collection.find(query).sort(sort);
        ArrayList<DBObject> l = Lists.newArrayList(cursor.iterator());
        for(DBObject o : l){
            System.out.println(o);
        }
        return l;
    }
}