You are here: Basics Operations & Concepts > Indexing > Check For Existing Indexes

Check For Existing Indexes

Sometime you may want to know if a index exists on a certain field. You can use the db4o-meta information to find out if a field is indexed.

StoredClass metaInfo = container.ext().storedClass(IndexedClass.class);
// list a fields and check if they have a index
for (StoredField field : metaInfo.getStoredFields()) {
    if(field.hasIndex()){
        System.out.println("The field '"+field.getName()+"' is indexed");
    } else{
        System.out.println("The field '"+field.getName()+"' isn't indexed");
    }
}
CheckForAndIndex.java: Check for a index