spring-data-neo4j 4.1.0.M1 上的 Neo4JRequest
Neo4JRequest on spring-data-neo4j 4.1.0.M1
以下参考文档here有在节点插入后更新空间索引的代码
final CloseableHttpClient httpClient = HttpClients.createDefault();
@Bean
ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() {
return new ApplicationListener<AfterSaveEvent>() {
@Override
public void onApplicationEvent(AfterSaveEvent event) {
Neo4jRequest<String> neo4jRequest = new DefaultRequest(httpClient);
if(event.getEntity() instanceof Person) {
Person person = (Person) event.getEntity();
//Construct the JSON statements
neo4jRequest.execute(endpoint,json);
}
}
};
}
问题si:
Neo4JRequest 接口在哪里?
它似乎从包裹中消失了,没有留下关于原因和方式的痕迹。
有人对索引更新有同样的问题吗?
谢谢
很遗憾,文档中的这一部分未针对 4.1 M1 进行更新。
以下是如何在 SDN 4.1 中执行此操作(参见 https://github.com/spring-projects/spring-data-neo4j/issues/332)
@Bean
ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() {
return new ApplicationListener<AfterSaveEvent>() {
@Override
public void onApplicationEvent(AfterSaveEvent event) {
if(event.getEntity() instanceof Person) {
Person person = (Person) event.getEntity();
String json = "construct the JSON";
HttpPost httpPost = new HttpPost(Components.driver().getConfiguration().getURI() + "/db/data/index/node/" + indexName);
try {
httpPost.setEntity(new StringEntity(json.toString()));
HttpRequest.execute(httpClient, httpPost, Components.driver().getConfiguration().getCredentials());
} catch (Exception e) {
//handle this
}
}
}
};
}
以下参考文档here有在节点插入后更新空间索引的代码
final CloseableHttpClient httpClient = HttpClients.createDefault();
@Bean
ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() {
return new ApplicationListener<AfterSaveEvent>() {
@Override
public void onApplicationEvent(AfterSaveEvent event) {
Neo4jRequest<String> neo4jRequest = new DefaultRequest(httpClient);
if(event.getEntity() instanceof Person) {
Person person = (Person) event.getEntity();
//Construct the JSON statements
neo4jRequest.execute(endpoint,json);
}
}
};
}
问题si: Neo4JRequest 接口在哪里? 它似乎从包裹中消失了,没有留下关于原因和方式的痕迹。
有人对索引更新有同样的问题吗?
谢谢
很遗憾,文档中的这一部分未针对 4.1 M1 进行更新。 以下是如何在 SDN 4.1 中执行此操作(参见 https://github.com/spring-projects/spring-data-neo4j/issues/332)
@Bean
ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() {
return new ApplicationListener<AfterSaveEvent>() {
@Override
public void onApplicationEvent(AfterSaveEvent event) {
if(event.getEntity() instanceof Person) {
Person person = (Person) event.getEntity();
String json = "construct the JSON";
HttpPost httpPost = new HttpPost(Components.driver().getConfiguration().getURI() + "/db/data/index/node/" + indexName);
try {
httpPost.setEntity(new StringEntity(json.toString()));
HttpRequest.execute(httpClient, httpPost, Components.driver().getConfiguration().getCredentials());
} catch (Exception e) {
//handle this
}
}
}
};
}