无法使用InProcessServer()SDN 4配置node_auto_index [英] Can't configure node_auto_index with InProcessServer() SDN 4

查看:80
本文介绍了无法使用InProcessServer()SDN 4配置node_auto_index的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我在getSessionFactory()上创建了全文node_auto_index.我实际上错过了如何配置Neo4j的当前内存中距离,因为我需要设置这些属性:

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

我读过《良好关系:Spring Data Neo4j指南》,

I read on "Good Relationships: The Spring Data Neo4j Guide Book" that

InProcessServer对于测试和开发环境很有用,但不建议用于生产环境.此实现将启动在可用本地端口上运行的CommunityNeoServer的新实例,并返回连接到该URL所需的URL.

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吗?即使已弃用我也应该使用它吗?在这种情况下,如何为支持节点自动索引的内存数据库配置它?

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?

推荐答案

如果要提供其他配置,可以提供自己的Neo4jServer实现,如下所示:

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

并使用它

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

这篇关于无法使用InProcessServer()SDN 4配置node_auto_index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆