You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by JimAld <ji...@db.com> on 2013/01/25 17:13:46 UTC

java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Hi,

The below code is throwing the exception:
java.lang.NumberFormatException: For input string: "000001.SZ" at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

when the "TopDocs docs = indexSearcher.search(phraseQuery, null, 10, sort);"
line is called. This only happens when the searchPattern contains a space
character. No other info is available in the exception.

The "000001.SZ" value is the first value in my index...
the index is a RAMDirectory...

Anyone have any ideas? Many Thanks.

Code:
BooleanQuery.setMaxClauseCount(clauseCount);			
searchPattern = QueryParser.escape(searchPattern);
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
IndexReader reader = IndexReader.open(index);
IndexSearcher indexSearcher = new IndexSearcher(reader);
			
PhraseQuery phraseQuery = new PhraseQuery();
Term term = new Term(fieldName, searchPattern);
phraseQuery.add(term);
phraseQuery.setSlop(0);
			
Sort sort = new Sort(new SortField(fieldName,SortField.Type.SCORE));
TopDocs docs = indexSearcher.search(phraseQuery, null, 10, sort);




--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-tp4036273.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Posted by JimAld <ji...@db.com>.
Thanks for the reply, but I'm not convinced this is the issue, I only have
~300 lines of code and have searched for "BYTE" with zero results. Also, I
upgraded my Lucene libraries to 4.1.0 and the issue goes away...



--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-tp4036273p4036694.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

this has nothing to do with PhraseQuery. The stack trace shows, that your code seems to have passed SortField.BYTE, so maybe you have some logic error? PhraseQuery by itself does not use the FieldCache, only the the result collector is using the cache and this one is independent from the query.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: JimAld [mailto:jim.alderman@db.com]
> Sent: Saturday, January 26, 2013 12:01 AM
> To: dev@lucene.apache.org
> Subject: Re: java.lang.NumberFormatException Using PhraseQuery with
> Lucene 4.0.0
> 
> Sure, here it is:
> 
> java.lang.NumberFormatException: For input string: "000001.SZ"
>         at
> java.lang.NumberFormatException.forInputString(NumberFormatException.
> java:48)
>         at java.lang.Integer.parseInt(Integer.java:458)
>         at java.lang.Byte.parseByte(Byte.java:151)
>         at java.lang.Byte.parseByte(Byte.java:108)
>         at
> org.apache.lucene.search.FieldCache$1.parseByte(FieldCache.java:130)
>         at
> org.apache.lucene.search.FieldCacheImpl$ByteCache.createValue(FieldCach
> eImpl.java:366)
>         at
> org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:24
> 8)
>         at
> org.apache.lucene.search.FieldCacheImpl.getBytes(FieldCacheImpl.java:329)
>         at
> org.apache.lucene.search.FieldComparator$ByteComparator.setNextReader
> (FieldComparator.java:271)
>         at
> org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringColl
> ector.setNextReader(TopFieldCollector.java:97)
>         at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:585)
>         at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:555)
>         at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:507)
>         at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:484)
>         at
> org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:309)
>         at
> com.db.gef.locates.index.impl.LuceneLocatesSearchIndex.getMatchingInde
> xedObjectPhrases(LuceneLocatesSearchIndex.java:361)
>         at
> com.db.gef.locates.cache.impl.services.CasheServiceImpl.lookupSecurity(Ca
> sheServiceImpl.java:304)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
> AopUtils.java:304)
>         at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoi
> npoint(ReflectiveMethodInvocation.java:182)
>         at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> ReflectiveMethodInvocation.java:149)
>         at
> org.springframework.remoting.support.RemoteInvocationTraceInterceptor.i
> nvoke(RemoteInvocationTraceInterceptor.java:70)
>         at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
> ReflectiveMethodInvocation.java:171)
>         at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDyna
> micAopProxy.java:204)
>         at $Proxy62.lookupSecurity(Unknown Source)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j
> ava:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
> sorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:15
> 7)
>         at
> org.springframework.remoting.caucho.Hessian2SkeletonInvoker.invoke(Hes
> sian2SkeletonInvoker.java:67)
>         at
> org.springframework.remoting.caucho.HessianServiceExporter.handleReque
> st(HessianServiceExporter.java:147)
>         at
> org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(
> HttpRequestHandlerAdapter.java:49)
>         at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherS
> ervlet.java:859)
>         at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherSe
> rvlet.java:793)
>         at
> org.springframework.web.servlet.FrameworkServlet.processRequest(Frame
> workServlet.java:476)
>         at
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkSer
> vlet.java:441)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>         at
> weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(Stub
> SecurityHelper.java:227)
>         at
> weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHel
> per.java:125)
>         at
> weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
>         at
> weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
>         at
> weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.r
> un(WebAppServletContext.java:3498)
>         at
> weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubj
> ect.java:321)
>         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
>         at
> weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
> ervletContext.java:2180)
>         at
> weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
> ontext.java:2086)
>         at
> weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1
> 406)
>         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
>         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
> 
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/java-
> lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-
> tp4036273p4036381.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional
> commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Posted by JimAld <ji...@db.com>.
Also, I made a mistake in my original post, the sort constructor used is
actually of type String as follows:

Sort sort = new Sort(new SortField(fieldName,SortField.Type.STRING));
			
All the rest of the code is correct.

Thanks.



--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-tp4036273p4036383.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Posted by JimAld <ji...@db.com>.
Sure, here it is:

java.lang.NumberFormatException: For input string: "000001.SZ"
        at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:458)
        at java.lang.Byte.parseByte(Byte.java:151)
        at java.lang.Byte.parseByte(Byte.java:108)
        at
org.apache.lucene.search.FieldCache$1.parseByte(FieldCache.java:130)
        at
org.apache.lucene.search.FieldCacheImpl$ByteCache.createValue(FieldCacheImpl.java:366)
        at
org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:248)
        at
org.apache.lucene.search.FieldCacheImpl.getBytes(FieldCacheImpl.java:329)
        at
org.apache.lucene.search.FieldComparator$ByteComparator.setNextReader(FieldComparator.java:271)
        at
org.apache.lucene.search.TopFieldCollector$OneComparatorNonScoringCollector.setNextReader(TopFieldCollector.java:97)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:585)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:555)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:507)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:484)
        at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:309)
        at
com.db.gef.locates.index.impl.LuceneLocatesSearchIndex.getMatchingIndexedObjectPhrases(LuceneLocatesSearchIndex.java:361)
        at
com.db.gef.locates.cache.impl.services.CasheServiceImpl.lookupSecurity(CasheServiceImpl.java:304)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
        at
org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:70)
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at $Proxy62.lookupSecurity(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
com.caucho.hessian.server.HessianSkeleton.invoke(HessianSkeleton.java:157)
        at
org.springframework.remoting.caucho.Hessian2SkeletonInvoker.invoke(Hessian2SkeletonInvoker.java:67)
        at
org.springframework.remoting.caucho.HessianServiceExporter.handleRequest(HessianServiceExporter.java:147)
        at
org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
        at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:859)
        at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793)
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
        at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
        at
weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
        at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
        at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at
weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
        at
weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
        at
weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)




--
View this message in context: http://lucene.472066.n3.nabble.com/java-lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-tp4036273p4036381.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: java.lang.NumberFormatException Using PhraseQuery with Lucene 4.0.0

Posted by Michael McCandless <lu...@mikemccandless.com>.
Can you provide the full stack trace?

Mike McCandless

http://blog.mikemccandless.com

On Fri, Jan 25, 2013 at 11:13 AM, JimAld <ji...@db.com> wrote:
> Hi,
>
> The below code is throwing the exception:
> java.lang.NumberFormatException: For input string: "000001.SZ" at
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
>
> when the "TopDocs docs = indexSearcher.search(phraseQuery, null, 10, sort);"
> line is called. This only happens when the searchPattern contains a space
> character. No other info is available in the exception.
>
> The "000001.SZ" value is the first value in my index...
> the index is a RAMDirectory...
>
> Anyone have any ideas? Many Thanks.
>
> Code:
> BooleanQuery.setMaxClauseCount(clauseCount);
> searchPattern = QueryParser.escape(searchPattern);
> Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
> IndexReader reader = IndexReader.open(index);
> IndexSearcher indexSearcher = new IndexSearcher(reader);
>
> PhraseQuery phraseQuery = new PhraseQuery();
> Term term = new Term(fieldName, searchPattern);
> phraseQuery.add(term);
> phraseQuery.setSlop(0);
>
> Sort sort = new Sort(new SortField(fieldName,SortField.Type.SCORE));
> TopDocs docs = indexSearcher.search(phraseQuery, null, 10, sort);
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/java-lang-NumberFormatException-Using-PhraseQuery-with-Lucene-4-0-0-tp4036273.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org