You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Trilok Prithvi <tr...@gmail.com> on 2014/12/17 22:58:37 UTC

Search Query with editdistance - throws Null Pointer

When I run the following query (Solr 4.10.2) with edit-distance, I'm
getting a null pointer exception:

*<host>/solr/select?q=fld:(Event
ID)&fl=strdist("eventid",fld_alphaonly,edit)*

<response><lst name="error"><str name="trace">java.lang.NullPointerException
</str><int name="code">500</int></lst></response>

It works if I remove the space between "Event ID", like:
*<host>/solr/select?q=fld:(EventID)&fl=strdist("eventid",fld_alphaonly,edit)*


Here is the schema details:

<field name="fld" type="text" indexed="true" stored="true"/>
<field name="fld_alphaonly" type="alphaonly" indexed="true" stored="true"/>
<copyField source="fld" dest="fld_alphaonly" />

<fieldType name="alphaonly" class="solr.TextField" sortMissingFirst="true"
omitNorms="true"> <analyzer> <charFilter class=
"solr.HTMLStripCharFilterFactory"/> <filter class=
"solr.LowerCaseFilterFactory"/> <filter class=
"solr.PatternReplaceFilterFactory" pattern="([^a-z])" replacement="" replace
="all"/> <tokenizer class="solr.KeywordTokenizerFactory"/> </analyzer> </
fieldType> <fieldType name="text" class="solr.TextField"
positionIncrementGap="100"> <analyzer> <tokenizer class=
"solr.StandardTokenizerFactory"/> <filter class="solr.StandardFilterFactory"
/> <filter class="solr.TrimFilterFactory"/> <filter class=
"solr.ICUFoldingFilterFactory"/> </analyzer> </fieldType>

Any suggestions would be appreciated.

Thanks
Trilok

Re: Search Query with editdistance - throws Null Pointer

Posted by Chris Hostetter <ho...@fucit.org>.
: But how do we avoid this error?
: Is there anyway to tweak the query and return empty result instead of null
: pointer exception?

did you look at the issue i linked to?

: >> probably this bug: https://issues.apache.org/jira/browse/SOLR-6540


>> A workarround in some contexts can be to wrap the strdist function in 
>> an "if" that checks exists(fieldname) and returns some suitable default 
>> if it's not found.
>> 
>> THIS:        if(exists(field_name_s),strdist("literal",field_name_s,edit),0)
>> INSTEAD OF:  strdist("literal",field_name_s,edit)




-Hoss
http://www.lucidworks.com/

Re: Search Query with editdistance - throws Null Pointer

Posted by Trilok Prithvi <tr...@gmail.com>.
Thanks Hoss.

But how do we avoid this error?
Is there anyway to tweak the query and return empty result instead of null
pointer exception?


On Thu, Dec 18, 2014 at 4:31 PM, Trilok Prithvi <tr...@gmail.com>
wrote:
>
> Here is the stack trace...
>
> java.lang.NullPointerException at
> org.apache.lucene.search.spell.LevensteinDistance.getDistance(LevensteinDistance.java:66)
> at
> org.apache.solr.search.function.distance.StringDistanceFunction$1.floatVal(StringDistanceFunction.java:54)
> at
> org.apache.lucene.queries.function.valuesource.ProductFloatFunction.func(ProductFloatFunction.java:40)
> at
> org.apache.lucene.queries.function.valuesource.MultiFloatFunction$1.floatVal(MultiFloatFunction.java:71)
> at
> org.apache.lucene.queries.function.docvalues.FloatDocValues.objectVal(FloatDocValues.java:71)
> at
> org.apache.solr.response.transform.ValueSourceAugmenter.transform(ValueSourceAugmenter.java:99)
> at
> org.apache.solr.response.TextResponseWriter.writeDocuments(TextResponseWriter.java:252)
> at
> org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:170)
> at org.apache.solr.response.XMLWriter.writeResponse(XMLWriter.java:112) at
> org.apache.solr.response.XMLResponseWriter.write(XMLResponseWriter.java:40)
> at
> org.apache.solr.servlet.SolrDispatchFilter.writeResponse(SolrDispatchFilter.java:765)
> at
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:426)
> at
> org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
> at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:190)
> at
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
> at
> org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2378)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:745)
>
>
>
> On Thu, Dec 18, 2014 at 3:06 PM, Chris Hostetter <hossman_lucene@fucit.org
> > wrote:
>>
>> : When I run the following query (Solr 4.10.2) with edit-distance, I'm
>> : getting a null pointer exception:
>> :
>> : *<host>/solr/select?q=fld:(Event
>> : ID)&fl=strdist("eventid",fld_alphaonly,edit)*
>>
>> probably this bug: https://issues.apache.org/jira/browse/SOLR-6540
>>
>> : <response><lst name="error"><str
>> name="trace">java.lang.NullPointerException
>> : </str><int name="code">500</int></lst></response>
>> :
>> : It works if I remove the space between "Event ID", like:
>> :
>> *<host>/solr/select?q=fld:(EventID)&fl=strdist("eventid",fld_alphaonly,edit)*
>>
>> because that's a different query, so it matches different docs, so when
>> you ask for the "fl" you get differnet things (evidently some docs have
>> the "fld_alphaonly" field, and some docs don't)
>>
>>
>> -Hoss
>> http://www.lucidworks.com/
>>
>

Re: Search Query with editdistance - throws Null Pointer

Posted by Trilok Prithvi <tr...@gmail.com>.
Here is the stack trace...

java.lang.NullPointerException at
org.apache.lucene.search.spell.LevensteinDistance.getDistance(LevensteinDistance.java:66)
at
org.apache.solr.search.function.distance.StringDistanceFunction$1.floatVal(StringDistanceFunction.java:54)
at
org.apache.lucene.queries.function.valuesource.ProductFloatFunction.func(ProductFloatFunction.java:40)
at
org.apache.lucene.queries.function.valuesource.MultiFloatFunction$1.floatVal(MultiFloatFunction.java:71)
at
org.apache.lucene.queries.function.docvalues.FloatDocValues.objectVal(FloatDocValues.java:71)
at
org.apache.solr.response.transform.ValueSourceAugmenter.transform(ValueSourceAugmenter.java:99)
at
org.apache.solr.response.TextResponseWriter.writeDocuments(TextResponseWriter.java:252)
at
org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:170)
at org.apache.solr.response.XMLWriter.writeResponse(XMLWriter.java:112) at
org.apache.solr.response.XMLResponseWriter.write(XMLResponseWriter.java:40)
at
org.apache.solr.servlet.SolrDispatchFilter.writeResponse(SolrDispatchFilter.java:765)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:426)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:190)
at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at
org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:2378)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)



On Thu, Dec 18, 2014 at 3:06 PM, Chris Hostetter <ho...@fucit.org>
wrote:
>
> : When I run the following query (Solr 4.10.2) with edit-distance, I'm
> : getting a null pointer exception:
> :
> : *<host>/solr/select?q=fld:(Event
> : ID)&fl=strdist("eventid",fld_alphaonly,edit)*
>
> probably this bug: https://issues.apache.org/jira/browse/SOLR-6540
>
> : <response><lst name="error"><str
> name="trace">java.lang.NullPointerException
> : </str><int name="code">500</int></lst></response>
> :
> : It works if I remove the space between "Event ID", like:
> :
> *<host>/solr/select?q=fld:(EventID)&fl=strdist("eventid",fld_alphaonly,edit)*
>
> because that's a different query, so it matches different docs, so when
> you ask for the "fl" you get differnet things (evidently some docs have
> the "fld_alphaonly" field, and some docs don't)
>
>
> -Hoss
> http://www.lucidworks.com/
>

Re: Search Query with editdistance - throws Null Pointer

Posted by Chris Hostetter <ho...@fucit.org>.
: When I run the following query (Solr 4.10.2) with edit-distance, I'm
: getting a null pointer exception:
: 
: *<host>/solr/select?q=fld:(Event
: ID)&fl=strdist("eventid",fld_alphaonly,edit)*

probably this bug: https://issues.apache.org/jira/browse/SOLR-6540

: <response><lst name="error"><str name="trace">java.lang.NullPointerException
: </str><int name="code">500</int></lst></response>
: 
: It works if I remove the space between "Event ID", like:
: *<host>/solr/select?q=fld:(EventID)&fl=strdist("eventid",fld_alphaonly,edit)*

because that's a different query, so it matches different docs, so when 
you ask for the "fl" you get differnet things (evidently some docs have 
the "fld_alphaonly" field, and some docs don't)


-Hoss
http://www.lucidworks.com/

Re: Search Query with editdistance - throws Null Pointer

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
What's the full stack trace in your server logs?

Regards,
   Alex.
----
Sign up for my Solr resources newsletter at http://www.solr-start.com/


On 17 December 2014 at 16:58, Trilok Prithvi <tr...@gmail.com> wrote:
> When I run the following query (Solr 4.10.2) with edit-distance, I'm
> getting a null pointer exception:
>
> *<host>/solr/select?q=fld:(Event
> ID)&fl=strdist("eventid",fld_alphaonly,edit)*
>
> <response><lst name="error"><str name="trace">java.lang.NullPointerException
> </str><int name="code">500</int></lst></response>
>
> It works if I remove the space between "Event ID", like:
> *<host>/solr/select?q=fld:(EventID)&fl=strdist("eventid",fld_alphaonly,edit)*
>
>
> Here is the schema details:
>
> <field name="fld" type="text" indexed="true" stored="true"/>
> <field name="fld_alphaonly" type="alphaonly" indexed="true" stored="true"/>
> <copyField source="fld" dest="fld_alphaonly" />
>
> <fieldType name="alphaonly" class="solr.TextField" sortMissingFirst="true"
> omitNorms="true"> <analyzer> <charFilter class=
> "solr.HTMLStripCharFilterFactory"/> <filter class=
> "solr.LowerCaseFilterFactory"/> <filter class=
> "solr.PatternReplaceFilterFactory" pattern="([^a-z])" replacement="" replace
> ="all"/> <tokenizer class="solr.KeywordTokenizerFactory"/> </analyzer> </
> fieldType> <fieldType name="text" class="solr.TextField"
> positionIncrementGap="100"> <analyzer> <tokenizer class=
> "solr.StandardTokenizerFactory"/> <filter class="solr.StandardFilterFactory"
> /> <filter class="solr.TrimFilterFactory"/> <filter class=
> "solr.ICUFoldingFilterFactory"/> </analyzer> </fieldType>
>
> Any suggestions would be appreciated.
>
> Thanks
> Trilok