title: Using @Query with an index lookup in START
body: <p>I have a Spring Data Neo4j project (version 2.3.2.RELEASE) in which I have a tree of <code>BesoinNode</code> entities. The <code>BesoinNode</code> contains a "name" field and a Set of children :</p>
  
  <pre class="lang-java prettyprint-override"><code>@NodeEntity
  public class BesoinNode implements Besoin {
  
      @GraphId private Long id;
  
      //@Indexed(indexName = "indexBesoin", indexType = FULLTEXT) private String name;
      @Indexed(indexName = "indexBesoin") private String name;
  
      @RelatedTo(elementClass = BesoinNode.class, type = "hasChild", direction = OUTGOING)
      private Set&lt;Besoin&gt; besoins = new HashSet&lt;Besoin&gt;();
  
      // etc.
  }
  </code></pre>
  
  <p>The associated repository is :</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface BesoinRepository extends GraphRepository&lt;BesoinNode&gt;, RelationshipOperationsRepository&lt;BesoinNode&gt;, NamedIndexRepository&lt;BesoinNode&gt; {
  
      // This query works
      @Query(value = "start parent=node({0}) match (parent)-[:hasChild]-&gt;(child) return child")
      Set&lt;BesoinNode&gt; findChildrenOf(Long id);
  
      // This query doesn't work
      @Query(value = "start parent=node:indexBesoin({name}) match (parent)-[:hasChild]-&gt;(child) return child")
      Set&lt;BesoinNode&gt; findChildrenOf(@Param("name") String name);
  
  }
  </code></pre>
  
  <p>The first query works, but to call it, I first need to retrieve the id of the node, something which is not necessary and that I would like to avoid. That's what the second query is supposed to do but I cannot make it to work. What can possibly be wrong?</p>
  
  <p>If I call <code>findChildrenOf("What a great name for a BesoinNode")</code> method I get a null pointer exception. The stacktrace is :</p>
  
  <pre><code>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.&lt;init&gt;(Term.java:38)
      at org.apache.lucene.queryParser.QueryParser.getFieldQuery(QueryParser.java:643)
      at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1436)
      at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1319)
      at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1245)
      at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1234)
      at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:206)
      at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:300)
      at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:227)
      at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:238)
      at org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexQuery(GDSBackedQueryContext.scala:87)
      at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:83)
      at org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$2.apply(IndexQueryBuilder.scala:81)
      at org.neo4j.cypher.internal.pipes.matching.MonoDirectionalTraversalMatcher.findMatchingPaths(MonodirectionalTraversalMatcher.scala:45)
      at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$internalCreateResults$1.apply(TraversalMatchPipe.scala:38)
      at org.neo4j.cypher.internal.pipes.TraversalMatchPipe$$anonfun$internalCreateResults$1.apply(TraversalMatchPipe.scala:35)
      at scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
      at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)
      at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
      at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
      at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:86)
      at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)
      at org.neo4j.cypher.PipeExecutionResult.hasNext(PipeExecutionResult.scala:157)
      at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327)
      at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29)
      at org.neo4j.cypher.PipeExecutionResult$$anon$1.hasNext(PipeExecutionResult.scala:73)
      at org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)
      at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:351)
      at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:370)
      at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:104)
      at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:81)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:323)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at com.sun.proxy.$Proxy29.findChildrenOf(Unknown Source)
  </code></pre>
  
  <p>Any help would be appreciated as I am fighting with this problem since two days.</p>