SpringDataIndex4不再支持@ Neo4j注释。对于独立的Neo4j数据库,我必须使用REST或web接口在自己身上部署索引。但是,由于数据库处于嵌入式模式,因此没有这样的接口。我是否必须以独立模式部署数据库,设置适当的索引,然后在嵌入式模式下使用数据库文件夹,还是在我的应用程序停止服务器后使用新4j-shell访问SDN4部署的数据库?
发布于 2016-03-09 09:15:38
您可以按建议来做,也可以在应用程序中获得GraphDatabaseService的句柄,并使用Java创建索引。下面是一个例子:
EmbeddedDriver embeddedDriver = (EmbeddedDriver) Components.driver();
GraphDatabaseService databaseService = embeddedDriver.getGraphDatabaseService();
try (Transaction tx = databaseService.beginTx()) {
databaseService.index().forNodes(indexName);
...
tx.success();
}基于注释的更新:
如果使用HttpDriver,则可以向rest端点发送请求。
String uri = Components.driver().getConfiguration().getURI() +
"/db/data/...";
HttpPost httpPost = new HttpPost(uri);
//Construct the JSON statements
try {
httpPost.setEntity(new StringEntity(json.toString()));
HttpRequest.execute(httpClient, httpPost,
Components.driver().getConfiguration().getCredentials());
} catch (Exception e) {
//Handle any exceptions
}https://stackoverflow.com/questions/35886761
复制相似问题