private synchronized Map < String , Map < String , Collection < Index < Node > > > > initIndexConfiguration ( ) { Map < String , Map < String , Collection < Index < Node > > > > indexesByLabelAndProperty = new HashMap <> ( ) ; try ( Transaction tx = graphDatabaseService . beginTx ( ) ) { final IndexManager indexManager = graphDatabaseService . index ( ) ; for ( String indexName : indexManager . nodeIndexNames ( ) ) { final Index < Node > index = indexManager . forNodes ( indexName ) ; Map < String , String > indexConfig = indexManager . getConfiguration ( index ) ; if ( Util . toBoolean ( indexConfig . get ( "autoUpdate" ) ) ) { String labels = indexConfig . getOrDefault ( "labels" , "" ) ; for ( String label : labels . split ( ":" ) ) { Map < String , Collection < Index < Node > > > propertyKeyToIndexMap = indexesByLabelAndProperty . computeIfAbsent ( label , s -> new HashMap <> ( ) ) ; String [ ] keysForLabel = indexConfig . getOrDefault ( "keysForLabel:" + label , "" ) . split ( ":" ) ; for ( String property : keysForLabel ) { propertyKeyToIndexMap . computeIfAbsent ( property , s -> new ArrayList <> ( ) ) . add ( index ) ; } } } } tx . success ( ) ; } return indexesByLabelAndProperty ; }
might be run from a scheduler so we need to make sure we have a transaction