Neo4j:SDN4中的Lucene查询语法

时间:2015-07-24 02:37:10

标签: neo4j lucene cypher spring-data-neo4j spring-data-neo4j-4

有人可以解释一下相应的Cypher Query语法,以便从下面提到的Repository查询中获得以下结果吗?以下提到的团队名称已保存到存储库中。

  • 洛杉矶湖人队
  • 洛杉矶快船队阿纳海姆
  • 金州勇士队
  • 阿纳海姆的洛杉矶Slappers
  • 阿纳海姆的洛杉矶拖鞋

我被建议下面的Cypher最终进入NPE。 Neo4j: Native Java API(or equivalent cypher query) in Spring Data Neo4j

    //Repository     
    public interface TeamRepository extends GraphRepository<Team>
    {
        @Query("start team=node:teamName({0}) RETURN team")
        List<Team> findByTeamName(String query);
    }

以下调用在调用时抛出NPE,如下所示:

teamRepository.findByTeamName("The Los Angeles Will be Playing in a state of Golden");

的NullPointerException:

Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675)
    at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.directv.service.Sports.main(Sports.java:134)
Caused by: java.lang.NullPointerException
    at org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:54)
    at org.apache.lucene.util.StringHelper.intern(StringHelper.java:39)
    at org.apache.lucene.index.Term.<init>(Term.java:38)
    at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)

1 个答案:

答案 0 :(得分:0)

经过一些试验和错误,我能够解决这个问题。正如@Michael Hunger指出的那样,这是查询中嵌入空格字符的问题。适当的查询是: @Query("START team=node:teamName('teamName:(*The Los Angeles Will be Playing in a state of Golden*)') RETURN team")