Maybe research FODMAPs? (Not to question anything which works, but maybe for others who read the thread.) N.I.C.E. approved, led by Kings, now thought to be a possible diet based solution for all manner of gut problems. Never heard of when a lot of doctors were training.
Basic idea is eliminate one group, then another, of potentially aggravating foods. Finally, personalise it. Odd things which are commonly aggressive to digestion are garlic and honey! Very few are actually allergic to gluten, but many find avoiding wheat helps. Often, whatever you love hates you, for instance a cheese addict might find they can manage, say, milk and yoghurt, but the cheese and butter must stay on their personal banned list.
A decent starting point, too, is to suspect chemicals. Simple one or two ingredient meals of organic food may be fine, while prepacked, ready meals, or factory farmed may make your system angry. There's a water filter called zero, which gives cleaner results than bottled spring water, and of course tap water may be safe to drink in the sense it has enough chlorine to kill the bacteria in it, but chlorine isn't always welcomed by human guts.
Michael Moseley, among others, is not enthusiastic about antibiotics destroying good gut bacteria, but most doctors were trained to try antibiotics for everything. These are invaluable of course, in the right circumstances, but possibly the way bodies evolved isn't invariably wrong.!