Can't configure node_auto_index with InProcessServer() SDN 4

谁说我不能喝 提交于 2019-12-13 05:27:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!