We evaluate the impact of an air gap and optimization of this air gap for the MP512 silicon detector array when operated in dosimetry mode for small photon field measurements in solid water. We present output factor measurements for 6MV and 10 MV photon beams with the square field sizes ranging from 0.5 to 10 cm2. The size of the air gap above the MP512 detector was changed from 0.5, 1.0, 1.2, 2.0 and 2.6 mm. We compare the output factors measurements of the MP512 with EBT3 film and the MOSkin dosimeter. For the two photon energies investigated, we find that the output factor measured by the MP512 reduce with increasing air gap and reducing of field size. The reduction in output factor is most pronounced for the 0.5 and 1 cm2 field sizes. The air gap of 0.5 mm and 1.2 mm showed good agreement with the EBT3 film and MOSkin output factor for 6 and 10 MV photon fields, respectively. The negligible effect on dosimetry for the field sizes larger than 4x4 cm2 demonstrates that the electronic disequilibrium caused by small air gap only influences the dosimetry measurements for small fields. The study shows that the output factor reduction is enhanced by increasing of air gap and demonstrates that the optimal air gap for the MP512 at 6 and 10 MV photon fields is 0.5mm.