How is matching determined?

It’s probably obvious that previous war rankings and current tier are the bread and butter but is there anything else?  Challenge stars or average level?  This war has been the absolute worse for my guild, we normally do much better but this war has shaken morality.