private Iterable<PropertyContainer> getMatchingNodesFromIndices( final IProgressMonitor monitor,
final GraphDatabaseService graphDb )
{
List<PropertyContainer> matches = new LinkedList<PropertyContainer>();
IndexManager indexManager = graphDb.index();
for ( String indexName : search.getNodeIndexNames() )
{
if ( !indexManager.existsForNodes( indexName ) )
{
continue;
}
Index<Node> nodeIndex = indexManager.forNodes( indexName );
Iterable<Node> hits;
switch ( search.getMode() )
{
case EXACT_MATCH:
hits = nodeIndex.get( search.getKey(), search.getValueOrQuery() );
break;
case QUERY:
String key = search.getKey();
hits = nodeIndex.query( key, search.getValueOrQuery() );
break;
default:
hits = null;
}
for ( Node hit : hits )
{
matches.add( hit );
}
}
for ( String indexName : search.getRelationshipIndexNames() )
{
if ( !indexManager.existsForRelationships( indexName ) )
{
continue;
}
Index<Relationship> relIndex = indexManager.forRelationships( indexName );
IndexHits<Relationship> hits;
switch ( search.getMode() )
{
case EXACT_MATCH:
hits = relIndex.get( search.getKey(), search.getValueOrQuery() );