Modified queryFactory to return map of query to retrieved docs