0

I access fulltext index by the findAllByQuery() repository method, it works fine, but i cannot pass pagination params, so i'm trying Cypher query which can use LIMIT, below are my testings:

Case 1 - Works fine but hardcoding

@Query( "START n=node:searchName('name:*test*') return n" )
EndResult<SomeGraphObject> findByName()

Case 2(Never work), give term = "*test*", throw exception

@Query( "START n=node:searchName('name:{0}') return n" )
EndResult<SomeGraphObject> findByName(String term)

Case 3(Partially working) - Works fine when give luceneExpression = "name:*test*", but doesn't work when give luceneExpression = "name:*test test*", i mean doesn't work when query string include space.

@Query( "START n=node:searchName({0}) return n" )
EndResult<SomeGraphObject> findByName(String luceneExpression)

Another issue is when i use findAllByQuery() repository method, index searchName will be created when first time create or query. But when i use Cypher query without creating index searchName, it will throw "Index searchName does not exist" error.

Any help will be greatly appreciated.

SomeGraphObject.java

@NodeEntity
public class SomeGraphObject {

    @GraphId Long id;

    @Indexed(indexName="searchName", indexType = IndexType.FULLTEXT)
    String name;

}
gozizibj
  • 285
  • 1
  • 5
  • 23

1 Answers1

0

For dynamic query expression you should only use the case 3 code. The reason space is not working, is because in Lucene space means another expression, but for some reason neo4j demands the field name in front of any expression meaning you should either use:
name:*test name:test*
name:(*test test*)

BTW I think that a query that begins with a '*' is illegal in Lucene, so it's kinda odd it works.