Cypher query with space...

1,339 views
Skip to first unread message

kiteflo

unread,
Feb 2, 2012, 3:15:55 AM2/2/12
to Neo4j
Hi,

we are using the following cypher query in order to do a "like-
search" (I know this could be done via derived query as well but we
have certain requirments forcing us to head for the none derived
approach...):

start offer=node:OFFER_NAME_SEARCH({searchString}) return offer

We pass in as searchString parmeter: name:*test* -> works 100%
We pass in as searchString parmeter: name:*my test* -> results in a
Nullpointer exception, see below.

Any idea what we have to do in order to search for more than a single
word on the index using cypher?

Thanx in advance,
Florian...


org.springframework.dao.InvalidDataAccessResourceUsageException: Error
executing statement start offer=node:OFFER_NAME_SEARCH({searchString})
return offer skip 0 limit 10; nested exception is
org.springframework.dao.InvalidDataAccessResourceUsageException: Error
executing statement start offer=node:OFFER_NAME_SEARCH({searchString})
return offer skip 0 limit 10; nested exception is
java.lang.NullPointerException
at
org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:
55)
at
org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:
87)
at
org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:
70)
at
org.springframework.data.repository.core.support.RepositoryFactorySupport
$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:
301)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
110)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
at
org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:
155)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
204)
at $Proxy59.findOfferByNameLike(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:
307)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
198)
at $Proxy60.findOfferByNameLike(Unknown Source)
at
com.helios.service.plain.OfferService.findOffersByNameLike(OfferService.java:
76)
at
sandbox.TestDataSetupFlo.testFindOfferByNameLike(TestDataSetupFlo.java:
162)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
at
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:
74)
at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:
82)
at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:
72)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:
231)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:
61)
at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:
70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:
174)
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:
467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
197)
Caused by:
org.springframework.dao.InvalidDataAccessResourceUsageException: Error
executing statement start offer=node:OFFER_NAME_SEARCH({searchString})
return offer skip 0 limit 10; nested exception is
java.lang.NullPointerException
at
org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:
65)
at
org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:
52)
... 47 more
Caused by: java.lang.NullPointerException
at
org.apache.lucene.util.SimpleStringInterner.intern(SimpleStringInterner.java:
54)
at org.apache.lucene.util.StringHelper.intern(StringHelper.java:36)
at org.apache.lucene.index.Term.<init>(Term.java:38)
at
org.apache.lucene.queryParser.QueryParser.getPrefixQuery(QueryParser.java:
1020)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:
1408)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:
1309)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:
1266)
at
org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:
1226)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:
206)
at org.neo4j.index.impl.lucene.IndexType.query(IndexType.java:281)
at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:
207)
at org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:
218)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun
$createStartPipe$3.apply(ExecutionPlanImpl.scala:206)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun
$createStartPipe$3.apply(ExecutionPlanImpl.scala:204)
at org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$createResults
$1.apply(StartPipe.scala:36)
at org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$createResults
$1.apply(StartPipe.scala:35)
at scala.collection.TraversableLike$$anonfun$flatMap
$1.apply(TraversableLike.scala:200)
at scala.collection.TraversableLike$$anonfun$flatMap
$1.apply(TraversableLike.scala:200)
at scala.collection.LinearSeqOptimized
$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike
$class.flatMap(TraversableLike.scala:200)
at scala.collection.immutable.List.flatMap(List.scala:45)
at
org.neo4j.cypher.internal.pipes.StartPipe.createResults(StartPipe.scala:
35)
at
org.neo4j.cypher.internal.pipes.ExtractPipe.createResults(ExtractPipe.scala:
41)
at
org.neo4j.cypher.internal.pipes.SlicePipe.createResults(SlicePipe.scala:
30)
at
org.neo4j.cypher.internal.pipes.ColumnFilterPipe.createResults(ColumnFilterPipe.scala:
33)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun
$prepareExecutionPlan$3.apply(ExecutionPlanImpl.scala:86)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun
$prepareExecutionPlan$3.apply(ExecutionPlanImpl.scala:86)
at
org.neo4j.cypher.internal.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:
33)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:59)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:55)
at
org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:
78)
at
org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:
63)
... 48 more

Michael Hunger

unread,
Feb 2, 2012, 3:36:27 AM2/2/12
to ne...@googlegroups.com
Florian, that shouldn't happen.

What version of SDN are you using at the moment?

Cheers

Michael

kiteflo

unread,
Feb 2, 2012, 5:03:46 AM2/2/12
to Neo4j
Hi Michael,

her is our current config:

<spring.version>3.0.7.RELEASE</spring.version>
<spring-data-graph.version>2.0.0.RELEASE</spring-data-graph.version>
<neo4j.version>1.6.M02</neo4j.version>
<neo4j.graphcollections.version>1.6-SNAPSHOT</
neo4j.graphcollections.version>

Thanx for checking, FLorian...


On 2 Feb., 09:36, Michael Hunger <michael.hun...@neotechnology.com>
wrote:

Michael Hunger

unread,
Feb 2, 2012, 5:17:46 AM2/2/12
to ne...@googlegroups.com
Florian,

it seems that in lucene you have to quote search terms that contain spaces and other characters.

So please try "name:\"*my test*\"".

Not sure about the stars if they should be inside or outside of the quote :)

HTH

Michael

kiteflo

unread,
Feb 2, 2012, 5:25:04 AM2/2/12
to Neo4j
Additional input:

I tried to setup a query without param via 7474-Query browser...the
result is similar, wehn using single word the query works, as soon as
there is a space in there the query does not work anymore...:

start a=node:OFFER_NAME_SEARCH("name:*Demo*") return a => works
start a=node:OFFER_NAME_SEARCH("name:*Demo World*") return a => does
not work, nothing is returned...

Maybe this helps to figure out the issue?

Cheers, Florian...
> > >    at...
>
> Erfahren Sie mehr »

Andres Taylor

unread,
Feb 2, 2012, 5:27:06 AM2/2/12
to ne...@googlegroups.com
You are using Lucene queries. You need to use string delimiters in for string with spaces in them.

Like: 


start a=node:OFFER_NAME_SEARCH('name:"*Demo World*"') return a

Andrés

kiteflo

unread,
Feb 2, 2012, 5:46:22 AM2/2/12
to Neo4j
hmmm...we tried this as well and I just triple tried but this one
(using 7474 query browser) does not work as well:

start a=node:OFFER_NAME_SEARCH('name:*Demo*') return a => works
start a=node:OFFER_NAME_SEARCH('name:"*Demo World*"') return a => does
not work

any other hints?
> ...
>
> Erfahren Sie mehr »

Andres Taylor

unread,
Feb 2, 2012, 6:19:44 AM2/2/12
to ne...@googlegroups.com
On Thu, Feb 2, 2012 at 11:46 AM, kiteflo <kit...@gmail.com> wrote:
start a=node:OFFER_NAME_SEARCH('name:"*Demo World*"') return a => does
not work

Same NPE from writing this?

Andrés

kiteflo

unread,
Feb 2, 2012, 6:30:21 AM2/2/12
to Neo4j
srrry - no clue on what you mean with "NPE"...

The query like this does not work as well if this was your question:

start a=node:OFFER_NAME_SEARCH('name:"*Demo World*"') return a

cheers + thanx for taking the time Florian

On 2 Feb., 12:19, Andres Taylor <and...@neotechnology.com> wrote:

Andres Taylor

unread,
Feb 2, 2012, 6:33:38 AM2/2/12
to ne...@googlegroups.com
Sorry - NPE == NullPointerException.

What do you mean when you say it does not work?

Andrés

kiteflo

unread,
Feb 2, 2012, 8:14:46 AM2/2/12
to Neo4j
Hi,

ok NPE - that makes sense...

no . currently I do not get any NPE as I'm firing down the query via
the neo data browser so I dont know why exactly it does not return any
results.

When running the query in a JUnit test it will drop out with a NPE but
the query browser simply does not return any results...

any help is still highly appreciated...

cheers, Flo...

kiteflo

unread,
Feb 2, 2012, 10:17:09 AM2/2/12
to Neo4j
Hi,

having had a "googly afternoon" I came across another user facing the
issue - maybe somenbody of u guys already got this on his radar?

http://forum.springsource.org/showthread.php?120985-Repository-derived-query-not-working-with-Strings-that-have-spaces

cheers, Florian...

Michael Hunger

unread,
Feb 2, 2012, 10:31:41 AM2/2/12
to ne...@googlegroups.com, Rick Bullotta
Florian,

this week has unfortunately been quite demanding, so we haven't caught up with everything, we will next week.

He runs into the same issue as you.

I started to look into it and it seems one needs quoting but OTOH I'm not sure about the stars (wildcard search) this is more a Lucene query syntax issue than a neo4j one.

So exact lookups work so far, but not wildcard matches. Haven't made any other progress. Sorry

Michael

Rick Bullotta

unread,
Feb 2, 2012, 10:42:31 AM2/2/12
to Michael Hunger, ne...@googlegroups.com
The issue is likely the actual query string that Neo4J is passing to Lucene.

A few comments:

- If you are fulltext indexing on the term you're searching for, the individual terms will be parsed separately (e.g. there will be no such thing as "embedded spaces")
- At present, wildcard searches with embedded spaces are not supported by the Lucene query parser, AFAIK (thus your issue with the wildcard query)
- Terms that contain whitespace need to be delimited. You can try:

Item lookupDrPepperByFullDescription = itemRepository.findByDescription("\"Dr Pepper 6 pack\"");

- You should *REALLY* avoid leading wildcard queries if you can. They are not very performant in Lucene (trailing wildcards are more performant, but you may run into issues with those as well, if you have a lot of terms in your index)

Hope this helps,

Rick

Bytor99999

unread,
Feb 3, 2012, 6:56:34 PM2/3/12
to Neo4j
Hi everyone. Michael told me about this thread going on and about the
same issue I have with the 6 pack of Dr Pepper. Typing this as I am
drinking a diet Dr Pepper, by the way.

I can now see that finding by a String that has spaces in it could be
construed as two different types of queries. One where you want the
full String to be searched with the spaces and one which works like a
Google Search where they are just individual keywords that is OR'd or
AND'd together, but could appear in any order in the text that you are
searching in.

In this thread here the String to search with is in a Cypher query,
whereas mine is using Spring Data Neo4J derived queries. In the case
of Cypher, I can see having to write different queries to support the
different types I described above. In Spring Data Neo4J the derived
queries should only work in one of the ways and probably would be too
much to try to support both, or to figure out what the coder wanted in
the first place.

For instance, my expectation in the code I wrote was that all the
words would be used as keywords, not as one long search String. And I
am sure there would be others that want it as one long search String.

So, I will have to not pass Strings with quotes to the derived like
query, but instead write code for those space String queries on my
own. Not a big deal. I will post Spring Data Neo4J related stuff in
the forums.

Thanks

Mark

Michael Hunger

unread,
Feb 3, 2012, 7:06:07 PM2/3/12
to ne...@googlegroups.com
The derived queries are also rendered and cypher queries, so the same reasoning applies.

What we could perhaps leverage are keywords that you can place in the query.

findByTitleLike(String title) -> search for the string with stars around it "title:*text*"
findByTitleExact(String title) -> search for the string, add quotes automatically
findByTitleRegexp(String title) -> regexp search on fields, don't know if lucene supports regexps
findByTitleAllKeywords(String title) -> split a string into keywords and AND them
findByTitleAnyKeywords(String title) -> split a string into keywords and OR them

Bytor99999

unread,
Feb 3, 2012, 7:13:48 PM2/3/12
to Neo4j
That would be sweet.

I just tried

Page<Item> drPepperByDescriptionLike =
itemRepository.findByDescriptionLike("*Dr* OR *Pepper* OR *6* OR
*pack*", new PageRequest(0,20));

That didn't work. ;)

Mark

On Feb 3, 4:06 pm, Michael Hunger <michael.hun...@neotechnology.com>
wrote:

Michael Hunger

unread,
Feb 3, 2012, 7:21:37 PM2/3/12
to ne...@googlegroups.com
What happened ?

Michael

Michael Hunger

unread,
Feb 3, 2012, 7:22:24 PM2/3/12
to ne...@googlegroups.com
Is description a fulltext indexed field?

@Indexed(type = FULLTEXT) String description

Am 04.02.2012 um 01:13 schrieb Bytor99999:

Bytor99999

unread,
Feb 3, 2012, 11:49:54 PM2/3/12
to Neo4j
"What happened?"

The same exception NullPointerException.

Here is the description mapping

@Indexed(indexName = DESCRIPTION_INDEX, indexType =
IndexType.FULLTEXT)
private String description;

I think in the docs it stated that you have to give it an index name?

Thanks

Mark

On Feb 3, 4:22 pm, Michael Hunger <michael.hun...@neotechnology.com>

Michael Hunger

unread,
Feb 4, 2012, 2:48:11 AM2/4/12
to ne...@googlegroups.com
B/c ~like already adds stars, did you try to quote it when passing it in?

Michael

Von meinem iPhone gesendet

Bytor99999

unread,
Feb 4, 2012, 2:28:27 PM2/4/12
to Neo4j
Yes

Page<Item> drPepperByDescriptionLike =
itemRepository.findByDescriptionLike("\"Dr Pepper 6 pack\"", new
PageRequest(0,20));

Works as an exact match like of the entire string. So not as keywords
but as a whole string. So "Dr Pepper Single" would not return the "Dr
Pepper 6 Pack" even though it has two of the keywords.

But I know you already knew/know that.

So what would be the best way to do a keyword "ANY" search in Spring
Data Neo4j

Mark

On Feb 3, 11:48 pm, Michael Hunger <michael.hun...@neopersistence.com>
wrote:
> B/c ~like already adds stars, did you try to quote it when passing it in?
>
> Michael
>
> Von meinem iPhone gesendet
>

Michael Hunger

unread,
Feb 4, 2012, 2:48:55 PM2/4/12
to ne...@googlegroups.com
I suggested in the last mail that like would add asterisks around the term which would in this case would lead to a failure.

So either it could analyse the params and auto-split and convert the individual parts into to an AND search.

Not sure about too much automatism?

Perhaps they findByDescriptionAnyKeyword and findByDescriptionAllKeyword would be better?

Michael

Bytor99999

unread,
Feb 4, 2012, 8:03:59 PM2/4/12
to Neo4j
I liked your suggestion with

"
findByTitleLike(String title) -> search for the string with stars
around it "title:*text*"
findByTitleExact(String title) -> search for the string, add quotes
automatically
findByTitleRegexp(String title) -> regexp search on fields, don't know
if lucene supports regexps
findByTitleAllKeywords(String title) -> split a string into keywords
and AND them
findByTitleAnyKeywords(String title) -> split a string into keywords
and OR them
"

Mark

On Feb 4, 11:48 am, Michael Hunger <michael.hun...@neotechnology.com>
wrote:

kiteflo

unread,
Feb 5, 2012, 1:57:54 PM2/5/12
to Neo4j
Hi Neo-friends...

we apologize for posting this issue resulting in a little response
wave, basically we discusse dour whole architecture this weekend and
ended up with the conclusion that the whole thread we started here
results from not having understand Lucene 100% - now we understood and
took several changes in our architecture, our wish to be able to
execute querries such as "*searchterm1* *searchterm2*"..." results
from an old fashioned relational approach thinking where you need to
be able to query your table like this; but as we are writing a
solution based on a graph DB approach this thinking is totally
outdated and from our point of view it's even "good" that we were
facing the NPE.

With our new approach we simply create keyword nodes, these are
related to the odes we finally wanna receive. The keyword nodes are
indexed via Lucene and the keywords area shared between serveral
entities sharing the same keywords. This results in much better search
results than hardcoded "term1* term2*" querying and enables us to
attach additional properties to the keywords. Our whole system
architecture now should scale much better rather than hoping Lucene
will do the job of hardcore querries...

Anybody facing the issue of being not able to search for combined
wildcard querries we would recommend rethinking the architecture - we
are really happy having done so!

Wish you all good monday morning start, cheers, FLorian;

Peter Neubauer

unread,
Feb 5, 2012, 2:02:52 PM2/5/12
to ne...@googlegroups.com

Florian,
This sounds like a great blog post on the evolution of your architecture? Might be very helpful to others as you say.

Glad it works out.

Send from a device with crappy keyboard and autocorrection.

/peter

Michael Hunger

unread,
Feb 7, 2012, 7:00:09 AM2/7/12
to Neo4j
Created a SDN issue for it: https://jira.springsource.org/browse/DATAGRAPH-192

Michael

On Feb 5, 7:57 pm, kiteflo <kite...@gmail.com> wrote:
> Hi Neo-friends...
>
> we apologize for posting this issue resulting in a little response
> wave, basically we discusse dour whole architecture this weekend and
> ended up with the conclusion that the whole thread we started here
> results from not having understandLucene100% - now we understood and
> took several changes in our architecture, our wish to be able to
> execute querries such as "*searchterm1* *searchterm2*"..." results
> from an old fashioned relational approach thinking where you need to
> be able to query your table like this; but as we are writing a
> solution based on a graph DB approach this thinking is totally
> outdated and from our point of view it's even "good" that we were
> facing the NPE.
>
> With our new approach we simply create keyword nodes, these are
> related to the odes we finally wanna receive. The keyword nodes are
> indexed viaLuceneand the keywords area shared between serveral
> entities sharing the same keywords. This results in much better search
> results than hardcoded "term1* term2*" querying and enables us to
> attach additional properties to the keywords. Our whole system
> architecture now should scale much better rather than hopingLucene
> will do the job of hardcore querries...
>
> Anybody facing the issue of being not able to search for combined
> wildcard querries we would recommend rethinking the architecture - we
> are really happy having done so!
>
> Wish you all good monday morning start, cheers, FLorian;
>
> On 5 Feb., 02:03, Bytor99999 <bytor99...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I liked your suggestion with
>
> > "
> > findByTitleLike(String title) -> search for the string with stars
> > around it "title:*text*"
> > findByTitleExact(String title) -> search for the string, add quotes
> > automatically
> > findByTitleRegexp(String title) -> regexp search on fields, don't know
> > iflucenesupports regexps
> > > >>>>>> findByTitleRegexp(String title) -> regexp search on fields, don't know iflucenesupports regexps
> > > >>>>>> findByTitleAllKeywords(String title) -> split a string into keywords and AND them
> > > >>>>>> findByTitleAnyKeywords(String title) -> split a string into keywords and OR them
> > > >>>>>> Am 04.02.2012 um 00:56 schrieb Bytor99999:
>
> > > >>>>>>> Hi everyone. Michael told me about this thread going on and about the
> > > >>>>>>> same issue I have with the 6 pack of Dr Pepper. Typing this as I am
> > > >>>>>>> drinking a diet Dr Pepper, by the way.
>
> > > >>>>>>> I can now see that finding by a String that has spaces in it could be
> > > >>>>>>> construed as two different types of queries. One where you want the
> > > >>>>>>> full String to be searched with the spaces and one which works like a
> > > >>>>>>> Google Search where they are just individual keywords that is OR'd or
> > > >>>>>>> AND'd together, but could appear in any order in the text that you are
> > > >>>>>>> searching in.
>
> > > >>>>>>> In this thread here the String to search with is in a Cypher query,
> > > >>>>>>> whereas mine is using Spring Data Neo4J derived queries. In the case
> > > >>>>>>> of Cypher, I can see having to write different queries to support the
> > > >>>>>>> different types I described above. In Spring Data Neo4J the derived
> > > >>>>>>> queries should only work in one of the ways and probably would be too
> > > >>>>>>> much to try to support both, or to figure out what the coder wanted in
> > > >>>>>>> the first place.
>
> > > >>>>>>> For instance, my expectation in the code I wrote was that all the
> > > >>>>>>> words would be used as keywords, not as one long search String. And I
> > > >>>>>>> am sure there would be others that want it as one long search String.
>
> > > >>>>>>> So, I will have to not pass Strings with quotes to the derived like
> > > >>>>>>> query, but instead write code for thosespaceString queries on my
> > > >>>>>>> own. Not a big deal. I will post Spring Data Neo4J related stuff in
> > > >>>>>>> the forums.
>
> > > >>>>>>> Thanks
>
> > > >>>>>>> Mark
>
> > > >>>>>>> On Feb 2, 7:42 am, Rick Bullotta <rick.bullo...@thingworx.com> wrote:
> > > >>>>>>>> The issue is likely the actual query string that Neo4J is passing toLucene.
>
> > > >>>>>>>> A few comments:
>
> > > >>>>>>>> - If you are fulltext indexing on the term you're searching for, the individual terms will be parsed separately (e.g. there will be no such thing as "embedded spaces")
> > > >>>>>>>> - At present, wildcard searches with embedded spaces are not supported by theLucenequery parser, AFAIK (thus your issue with the wildcard query)
> > > >>>>>>>> - Terms that contain whitespace need to be delimited.  You can try:
>
> > > >>>>>>>>         Item lookupDrPepperByFullDescription = itemRepository.findByDescription("\"Dr Pepper 6 pack\"");
>
> > > >>>>>>>> - You should *REALLY* avoid leading wildcard queries if you can.  They are not very performant inLucene(trailing wildcards are more performant, but you may run into issues with those as well, if you have a lot of terms in your index)
>
> > > >>>>>>>> Hope this helps,

Bytor99999

unread,
Jun 21, 2012, 1:52:20 AM6/21/12
to ne...@googlegroups.com, Michael Hunger
Wow, after a long number of months I have come back to this.

Rick, I finally got my String to be delimited like

itemRepository.findByDescription("\"Dr Pepper 6 pack\"");

And that is working for me enough for my needs. 

Thanks

Mark
Reply all
Reply to author
Forward
0 new messages