I need to be able to search for substrings in a text field, via a parameterised repository method, in neo4j 1.9.5
Ideally I want to be able to call
getInteractionsByTermAndDateRange(String term,
long startMillis, long endMillis
and get back every WRInteraction where the 'content' field contains 'term', with the pubMillis value within the specified range( 'content' is specified as a FULLTEXT index in the WRInteraction object declaration)
First attempt:
@Query("START n=node:WRInteraction('content:*{0}*') " + " WHERE "
+ " n.pubMillis >= {1} AND n.pubMillis <= {2}" + " RETURN "
+ " n")
Iterable<WRInteraction> getInteractionsByTermAndDateRange(String term,
long startMillis, long endMillis);
This throws
Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse 'content:*{0}*':
Encountered " "}" "} "" at line 1, column 11.
Was expecting one of:
"TO" ...
<RANGEEX_QUOTED> ...
<RANGEEX_GOOP> ...
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211) ~[lucene-core-3.6.2.jar:3.6.2 1423725 - rmuir - 2012-12-18 19:45:40]
at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:300) ~[neo4j-lucene-index-1.9.5.jar:1.9.5]
Second try -- pass the whole lucene query via the parameter:
@Query("START n=node:WRInteraction('content:{0}') " + " WHERE "
+ " n.pubMillis >= {1} AND n.pubMillis <= {2}" + " RETURN "
+ " n")
doesn't fare any better... what's the pattern I should be using here? The key requirement is to be able to pass a substring to a repository method as a parameter, and return any WRInteractions where that substring is present int he 'content' field. Should be easy, right?
Thanks