Add support for immutable indices.

Refs #1344
I used this to test the functionality. I'm happy for it to be removed if it doesn't add value to the example.