问题
I'm using the following java configuration for my Neo4j (using SDN 4.0.0.RELEASE) based application, with unit tests:
...
@Bean
public Neo4jServer neo4jServer() {
return new InProcessServer();
}
@Bean
public SessionFactory getSessionFactory() {
Neo4jRequest<String> neo4jRequest = new DefaultRequest(httpClient);
String json = "{" + "\"name\" : \"node_auto_index\", " + "\"config\" : {" + "\"type\" : \"fulltext\", "
+ "\"provider\" : \"lucene\"" + "}" + "}";
neo4jRequest.execute(neo4jServer().url() + "db/data/index/node/", json);
return new SessionFactory("org.myproject.domain");
}
...
I created on getSessionFactory()
a full-text node_auto_index
. I'm actually missing how to configure my current in-memory istance of Neo4j, because I need to set those properties:
node_auto_indexing=true
node_keys_indexable=title
I read on "Good Relationships: The Spring Data Neo4j Guide Book" that
InProcessServer is useful for test and development environments, but is not recommended for production use. This implementation will start a new instance of CommunityNeoServer running on an available local port and return the URL needed to connect to it.
Do I need to use CommunityNeoServer
instead? Should I use it even if it's deprecated? In this case, how can I configure it for an in-memory database that will support node auto indexing?
回答1:
If you want to supply additional configuration, you can provide your own implementation of Neo4jServer
, like this:
public class AutoIndexTestServer implements Neo4jServer {
final String uri;
public AutoIndexTestServer() {
try {
ServerControls controls = TestServerBuilders.newInProcessBuilder()
.withConfig("dbms.security.auth_enabled", "false")
.withConfig("node_auto_indexing", "true")
.withConfig("node_keys_indexable", "title")
.newServer();
uri = controls.httpURI().toString();
}
catch (Exception e) {
throw new RuntimeException("Could not start inprocess server",e);
}
}
@Override
public String url() {
return uri;
}
@Override
public String username() {
return null;
}
@Override
public String password() {
return null;
}
}
and use it
@Bean
public Neo4jServer neo4jServer() {
return new AutoIndexTestServer();
}
来源:https://stackoverflow.com/questions/34340619/cant-configure-node-auto-index-with-inprocessserver-sdn-4