Functional diversity within isogenic spatially organised bacterial populations has been shown to trigger emergent community properties such as stress tolerance. Considering gadB gene encoding a key glutamate decarboxylase involved in E. coli tolerance to acidic conditions, we investigated its expression in hydrogels mimicking the texture of some structured food matrices (such as minced meat or soft cheese). Taking advantage of confocal laser scanning microscopy combined with a genetically-engineered dual fluorescent reporter system, it was possible to visualise the spatial patterns of bacterial gene expression from in-gel microcolonies. In E. coli O157:H7 microcolonies, gadB showed radically different expression patterns between neutral (pH 7) or acidic (pH 5) hydrogels. Differential spatial expression was determined in acidic hydrogels with a strong expression of gadB at the microcolony periphery. Strikingly, very similar spatial patterns of gadB expression were further observed for E. coli O157:H7 grown in the presence of L. lactis. Considering the ingestion of contaminated foodstuff, survival of E. coli O157:H7 to acidic stomachal stress (pH 2) was significantly increased for bacterial cells grown in microcolonies in acidic hydrogels compared to planktonic cells. These findings have significant implications for risk assessment and public health as they highlight inherent differences in bacterial physiology and virulence between liquid and structured food products. The contrasting characteristics observed underscore the need to consider the distinct challenges posed by these food types, thereby emphasising the importance of tailored risk mitigation strategies.