Spring Data Neo4j是否支持在findByAttribtuteContains(....)中使用空格进行通配符搜索

时间:2015-01-13 09:58:06

标签: regex spring cypher spring-data spring-data-neo4j

我在person类上有一个全文索引名称属性。但是,当我尝试使用类似" Joe Bloggs"这样的名称进行搜索时,我会尝试搜索。我使用GraphRepository finder方法获得以下异常

            org.springframework.data.neo4j.repository.query.RepositoryQueryException: Value for class java.lang.String name rel: false idx: true contains whitespace. It cannot be used with wildcards Linda Mendez
                at org.springframework.data.neo4j.repository.query.QueryTemplates.checkWhiteSpace(QueryTemplates.java:116)
                at org.springframework.data.neo4j.repository.query.QueryTemplates.formatIndexValue(QueryTemplates.java:98)
                at org.springframework.data.neo4j.repository.query.QueryTemplates.formatIndexQuery(QueryTemplates.java:90)
                at org.springframework.data.neo4j.repository.query.FullTextIndexBasedStartClause.renderQuery(FullTextIndexBasedStartClause.java:78)
                at org.springframework.data.neo4j.repository.query.FullTextIndexBasedStartClause.resolveParameters(FullTextIndexBasedStartClause.java:68)
                at org.springframework.data.neo4j.repository.query.CypherQuery.resolveParameters(CypherQuery.java:170)
                at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.resolveParameters(DerivedCypherRepositoryQuery.java:65)
                at org.springframework.data.neo4j.repository.query.GraphQueryMethod.resolveParams(GraphQueryMethod.java:88)
                at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.resolveParams(GraphRepositoryQuery.java:94)
                at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery$1.doWithGraph(GraphRepositoryQuery.java:86)
                at org.springframework.data.neo4j.support.Neo4jTemplate.doExecute(Neo4jTemplate.java:456)
                at org.springframework.data.neo4j.support.Neo4jTemplate.access$000(Neo4jTemplate.java:86)
                at org.springframework.data.neo4j.support.Neo4jTemplate$2.doInTransaction(Neo4jTemplate.java:470)
                at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
                at org.springframework.data.neo4j.support.Neo4jTemplate.exec(Neo4jTemplate.java:467)
                at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:82)
                at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.execute(DerivedCypherRepositoryQuery.java:39)
                at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:384)
                at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:344)
                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
                at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
                at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
                at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
                at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
                at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
                at com.sun.proxy.$Proxy82.findByNameStartingWithIgnoreCaseOrderByNameAsc(Unknown Source)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
                at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201)
                at com.sun.proxy.$Proxy83.findByNameStartingWithIgnoreCaseOrderByNameAsc(Unknown Source)
                at test.com.erranda.prototype.GraphTest.test(GraphTest.java:171)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
                at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
                at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
                at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
                at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
                at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
                at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
                at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
                at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
                at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:233)
                at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
                at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
                at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
                at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
                at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
                at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
                at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
                at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
                at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
                at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:176)
                at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
                at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
                at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

  List<Person> findByUsernameContainsIgnoreCaseOrderByNameAsc(String name, Pageable pageRequest);

我尝试使用\来转义空格,将名称括在括号中。但是,findByLike与空格一起使用,但它似乎只能逐字逐句地工作,这对自动完成不利。

0 个答案:

没有答案