I find it's best to just sweep up the hardwood floors and then mop the remaining dirt away from the hardwood floors which keeps them clean.
Using a vacuum with a brush could actually scratch the hardwood floors so it's best to avoid vacuuming the hardwood floors with an upright vacuum with a rotating brush.
However if you do want to vacuum the hardwood floors then use a vacuum cleaner with a hose and attachment to go over the hardwood floors with to avoid scratching the hardwood floors.