我无法使用JAVA API创建索引。 我的代码是:
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
registerShutdownHook();
// END SNIPPET: startDb
// START SNIPPET: addUsers
Transaction tx = graphDb.beginTx();
try
{
nodeIndex = graphDb.index().forNodes( "nodes" );
// Create some users and index their names with the IndexService
for ( int id = 0; id < 100; id++ )
{
createAndIndexUser( idToUserName( id ) );
}
// END SNIPPET: addUsers
// Find a user through the search index
// START SNIPPET: findUser
int idToFind = 45;
String userName = idToUserName( idToFind );
Node foundUser = nodeIndex.get( USERNAME_KEY, userName ).getSingle();
System.out.println( "The username of user " + idToFind + " is "
+ foundUser.getProperty( USERNAME_KEY ) );
// END SNIPPET: findUser
// Delete the persons and remove them from the index
for ( Node user : nodeIndex.query( USERNAME_KEY, "*" ) )
{
nodeIndex.remove( user, USERNAME_KEY, user.getProperty( USERNAME_KEY ) );
user.delete();
}
tx.success();
}
finally
{
tx.finish();
}
错误:
线程“main”中的异常java.lang.IllegalArgumentException:否 索引提供商'lucene'找到了。也许是预期的提供者(或者一个 更多的依赖项)不在类路径上,或者没有 负荷。
at org.neo4j.kernel.IndexManagerImpl.getIndexProvider(IndexManagerImpl.java:90)
at org.neo4j.kernel.IndexManagerImpl.findIndexConfig(IndexManagerImpl.java:141)
在org.neo4j.kernel.IndexManagerImpl.getOrCreateIndexConfig(IndexManagerImpl.java:208)
at org.neo4j.kernel.IndexManagerImpl.getOrCreateNodeIndex(IndexManagerImpl.java:318)
at org.neo4j.kernel.NodeAutoIndexerImpl.getIndexInternal(NodeAutoIndexerImpl.java:85)
at org.neo4j.kernel.AbstractAutoIndexerImpl.getAutoIndex(AbstractAutoIndexerImpl.java:82)
在com.neo4j.Indexing.main(Indexing.java:39) Java结果:1