Actually you don't have to change the gap limit at all. You can use the following command in the console to get the private key for a specific index:
getprivatekeyforpath("m/0'/50000")
I didn't know about this command. Thanks for sharing that, but I think you should remove the apostrophe after the 0 and the command should be
getprivatekeyforpath("m/0/50000"). Otherwise, you will get an incorrect private key.