These seem to be ways of bringing actions to a court. How do they differ and compare?
These are different terms for initiating documents. What one court or jurisdiction calls a petition, another might call an application. "Complaint" may not have a technical meaning in some contexts or jurisdictions, but often it is used to refer to the initiating document at a specialist tribunal. There are other names for initiating documents: notice of civil claim, notice of action, etc.
There is no way to know which terms have a technical meaning and what those meanings are without looking to the rules and practice in a particular jurisdiction.
"Indictment" is an initiating document in a criminal prosecution. But there are also "informations" (generally implying lesser charges).