Index implementation for primary/secondary -- untested.