无法使用 InProcessServer() SDN 4 配置 node_auto_index

Can't configure node_auto_index with InProcessServer() SDN 4

我正在为基于 Neo4j(使用 SDN 4.0.0.RELEASE)的应用程序使用以下 java 配置,并进行单元测试:

...
@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");
}
...

我在 getSessionFactory() 上创建了一篇全文 node_auto_index。我实际上缺少如何配置我当前的 Neo4j 内存中,因为我需要设置这些属性:

node_auto_indexing=true
node_keys_indexable=title

我在 "Good Relationships: The Spring Data Neo4j Guide Book" 上看到

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.

我需要改用 CommunityNeoServer 吗?即使它已被弃用,我也应该使用它吗?在这种情况下,如何为支持节点自动索引的内存数据库配置它?

如果您想提供额外的配置,您可以提供自己的 Neo4jServer 实现,如下所示:

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;
    }
}

并使用它

 @Bean
 public Neo4jServer neo4jServer() {
     return new AutoIndexTestServer();
 }