SDN finder method throws EXCEPTION when params have white spaces

151 views
Skip to first unread message

Abdul Azeez Shaik

unread,
Sep 1, 2012, 12:22:34 PM9/1/12
to ne...@googlegroups.com
Hi,

SDN finder method is failing with REstResultException whenever spaces are there in parameters.
Here is my use case,
@NodeEntiry
Class User{

@Indexed(indexName="username", indexType=IndexType.FULLTEXT)

String username;}

Here is my finder function in repository

User findByusername(String username);

Here is my finder call,

User user =  userRepo.findByusername("Spring data"); This call throws below exception...

However, everything works file, when param is just "Spring"

Kindly let me know your suggestions to resolve this.

Exception:

21:01:47,670 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/netvogueweb].[dispatcher]] (http--127.0.0.1-8080-6) Servlet.service() for servlet dispatcher threw exception: org.neo4j.rest.graphdb.RestResultException: null at

BadInputException

   org.neo4j.server.rest.repr.RepresentationExceptionHandlingIterable.exceptionOnHasNext(RepresentationExceptionHandlingIterable.java:51)

   org.neo4j.helpers.collection.ExceptionHandlingIterable$1.hasNext(ExceptionHandlingIterable.java:61)

   org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42)

   org.neo4j.server.rest.repr.ListRepresentation.serialize(ListRepresentation.java:58)

   org.neo4j.server.rest.repr.Serializer.serialize(Serializer.java:75)

   org.neo4j.server.rest.repr.MappingSerializer.putList(MappingSerializer.java:61)

   org.neo4j.server.rest.repr.CypherResultRepresentation.serialize(CypherResultRepresentation.java:50)

   org.neo4j.server.rest.repr.MappingRepresentation.serialize(MappingRepresentation.java:42)

   org.neo4j.server.rest.repr.OutputFormat$1.write(OutputFormat.java:133)

   org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)

at org.neo4j.rest.graphdb.ExecutingRestAPI.query(ExecutingRestAPI.java:488) [neo4j-rest-graphdb-1.8.RC1.jar:1.8.RC1]

at org.neo4j.rest.graphdb.RestAPIFacade.query(RestAPIFacade.java:231) [neo4j-rest-graphdb-1.8.RC1.jar:1.8.RC1]

at org.neo4j.rest.graphdb.query.RestCypherQueryEngine.query(RestCypherQueryEngine.java:50) [neo4j-rest-graphdb-1.8.RC1.jar:1.8.RC1]

at org.springframework.data.neo4j.rest.SpringRestCypherQueryEngine.query(SpringRestCypherQueryEngine.java:41) [spring-data-neo4j-rest-2.1.0.RC3.jar:]

at org.springframework.data.neo4j.rest.SpringRestCypherQueryEngine.query(SpringRestCypherQueryEngine.java:27) [spring-data-neo4j-rest-2.1.0.RC3.jar:]

at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:96) [spring-data-neo4j-2.1.0.RC3.jar:]

at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) [spring-data-neo4j-2.1.0.RC3.jar:]

at org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery.execute(DerivedCypherRepositoryQuery.java:36) [spring-data-neo4j-2.1.0.RC3.jar:]

at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313) [spring-data-commons-core-1.4.0.RC1.jar:]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) [spring-tx-3.0.7.RELEASE.jar:3.0.7.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) [spring-tx-3.0.7.RELEASE.jar:3.0.7.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) [spring-aop-3.1.2.RELEASE.jar:3.1.2.RELEASE]

at $Proxy290.findByusername(Unknown Source) at org.netvogue.server.neo4japi.service.BoutiqueServiceImpl.GetOrCreateUser(BoutiqueServiceImpl.java:83) [netvogue-database-api-1.0-SNAPSHOT.jar:]

at org.netvogue.server.webmvc.converters.UserConverterFactory$UserConverter.convert(UserConverterFactory.java:70) [classes:]

Thanks,

Abdul

Michael Hunger

unread,
Sep 1, 2012, 3:19:27 PM9/1/12
to ne...@googlegroups.com
You have to quote it. With \"


Sent from mobile device
--
 
 

Abdul Azeez Shaik

unread,
Sep 2, 2012, 6:24:48 PM9/2/12
to ne...@googlegroups.com
Thanks for the information Michael.
Have another issue with executing Cypher query from SDN.
It works fine, when i executed on neo4j console. Issue is with passing parameter. Can you please correct me?

@Query( "START n=node:search(\"name:*{brandname}*\") RETURN n")

Iterable<Brand> findBynameSearch(@Param("brandname") String brandname);

Exception is:
exception: org.neo4j.rest.graphdb.RestResultException: org.apache.lucene.queryParser.ParseException: Cannot parse 'name:*{brandname}*': Encountered " "}" "} "" at line 1, column 16.
Was expecting one of:
    "TO" ...
    <RANGEEX_QUOTED> ...
    <RANGEEX_GOOP> ...
     at


--
 
 

Michael Hunger

unread,
Sep 2, 2012, 7:04:39 PM9/2/12
to ne...@googlegroups.com
You have to pass in the whole index-query string:

@Query"START n=node:search({query}) RETURN n")

Iterable<Brand> findBynameSearch(@Param("query") String query);

String query = \"name:*"+brandname+"*\"


--
 
 

Abdul Azeez Shaik

unread,
Sep 2, 2012, 7:28:35 PM9/2/12
to ne...@googlegroups.com
It worked in first trail itself. Thanks for the quick response.

--
 
 

Abdul Azeez Shaik

unread,
Sep 3, 2012, 12:36:53 AM9/3/12
to ne...@googlegroups.com
Hi Michael,

This one is not working with pattern matching.
for example,
START n=node:search("name:\"abdul azeez\"") RETURN n; -- WORKING
START n=node:search("name:*abdul*") RETURN n; -- WORKING 
START n=node:search("name:\"*abdul*\"") RETURN n; -- NOT WORKING
START n=node:search("name:\"*abdul azeez*\"") RETURN n; -- NOT WORKING

Is there a way to work while spaces and pattern matching in same query param?

Thanks,
Abdul

On Sun, Sep 2, 2012 at 12:49 AM, Michael Hunger <michael...@neopersistence.com> wrote:
--
 
 

Michael Hunger

unread,
Sep 3, 2012, 1:08:25 AM9/3/12
to ne...@googlegroups.com
Try to put the stars outside the quotes

Sent from mobile device
--
 
 

Abdul Azeez Shaik

unread,
Sep 3, 2012, 2:39:15 AM9/3/12
to ne...@googlegroups.com
I tried that. Its not working.
I tried directly on neo4j console itself.

--
 
 

Peter Neubauer

unread,
Sep 3, 2012, 4:44:59 AM9/3/12
to ne...@googlegroups.com
Abdul,
there are several layers of String processing going on, including
Lucene processing the String, try more escapes :)


start n=node:node_auto_index("name:Neo\\\"") return n

http://console.neo4j.org/r/jyrcyv

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.
> --
>
>

Abdul Azeez Shaik

unread,
Sep 3, 2012, 9:28:09 AM9/3/12
to ne...@googlegroups.com
I tried in below ways, it throws "Invalid escape sequence"
START n=node:search("name:\*\"abdul azeez\"\*") RETURN n; -- NOT WORKING
START n=node:search("name:\"\*abdul azeez\*\"") RETURN n; -- NOT WORKING

--



Peter Neubauer

unread,
Sep 3, 2012, 9:33:57 AM9/3/12
to ne...@googlegroups.com
Abdul,
I think you need three \\\ for every escape " and \\ for *, see

START n=node:node_auto_index("name:\\\"\\*abdul azeez\\*\\\"") RETURN n;

http://console.neo4j.org/r/n5ndyp



Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.


On Mon, Sep 3, 2012 at 3:28 PM, Abdul Azeez Shaik
> --
>
>
Reply all
Reply to author
Forward
0 new messages