Checking the Existence of an Index Entry

Using RecordLayer is there an easy way to check the existence of an index entry? I see there’s loadIndexEntryRecord which will check the index and then load the record associated with it (if it exists). I was wondering if there’s a way to skip that and to return true or false whether or not the index entry exists at all.

You can’t really scan an index and know if an entry is missing…to do this, you have to scan the records, compute the index entries from the records, then check to see if those entries are missing.

If, instead, you want to know if you have index entries that do not point to records, you can use:

The IndexOrphanBehavior option allows you to scan the index and return entries even if they do not point to records.

In general, though, if you are looking to check for any kind of index corruption (entries that don’t point to records, or records for which entries are missing), you can look at IndexMaintainer.validateEntries(). Currently, this is only implemented for Value indexes (validating things like aggregate indexes and Rank/Text indexes is much harder).