Step 1Place the lentils in a small saucepan and cover with water. Bring to a boil over high heat and cook until the lentils have softened but still have a little bite, 12 to 15 minutes. Drain.
Step 2Peel and thinly slice the onions. Sprinkle over the flour and 1 teaspoon salt, and mix well. In a saucepan, heat up the sunflower oil over high heat. Check the temperature of the oil by tossing in a small piece of onion; it should sizzle vigorously.
Step 3Reduce the temperature to medium-high and fry the onions, one-third at a time, stirring occasionally, until golden brown and crispy, 5 to 7 minutes. Transfer to a colander lined with paper towels and sprinkle over a little more salt. Repeat with the remaining onions, adding additional oil as needed.
Step 4Discard the oil and wipe the saucepan clean. Add the cumin and coriander seeds. Place the pan over medium heat and toast the seeds until lightly toasted, 1 to 2 minutes. Stir in the rice, olive oil, turmeric, allspice, cinnamon, sugar, one-half teaspoon salt and a good sprinkling of pepper. Stir to coat the rice with the oil and then add the cooked lentils and the water. Bring the mixture to a boil, then cover with a lid and simmer for 15 minutes.
Step 5Remove from heat, remove the lid and quickly cover the pan with a clean tea towel. Seal tightly with the lid and set aside for 10 minutes.
Step 6Add half of the fried onion to the rice and lentils and stir gently with a fork; this makes about 8 cups mejadra. Top with the rest of the onion.