SAN FRANCISCO — A San Jose federal judge on Thursday threw out most of the claims against Facebook Inc. in a privacy suit that claims it shared personal information with advertisers without users’ consent.

The ruling by Chief Judge James Ware signals the difficulty that plaintiffs may have in recovering damages from social media companies for alleged privacy breaches.