Pakistani officials say security forces have killed at least 23 militants in fighting that took place during a search operation in the country 's northwest .