How fit pairwise ranking models in xgBoost?
According to the XGBoost documentation, XGboost expects:

the examples of a same group to be consecutive examples,
a list with the size of each group (which you can set with set_group method of DMatrix in Python).