You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Hoss Man (JIRA)" <ji...@apache.org> on 2014/09/18 23:44:33 UTC
[jira] [Commented] (SOLR-6540) strdist() causes NPE if doc is
missing field
[ https://issues.apache.org/jira/browse/SOLR-6540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14139573#comment-14139573 ]
Hoss Man commented on SOLR-6540:
--------------------------------
Steps to reproduce...
{noformat}
hossman@frisbee:~$ curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/collection1/update?commit=true' --data-binary '[{"id":"1","foo_s":"yak"},{"id":"2","foo_s":"zak"}]'
{"responseHeader":{"status":0,"QTime":369}}
hossman@frisbee:~$ curl 'http://localhost:8983/solr/collection1/select?q=*:*&indent=true&wt=json&fl=id,strdist("ack",foo_s,edit)'{
"responseHeader":{
"status":0,
"QTime":15,
"params":{
"fl":"id,strdist(\"ack\",foo_s,edit)",
"indent":"true",
"q":"*:*",
"wt":"json"}},
"response":{"numFound":2,"start":0,"docs":[
{
"id":"1",
"strdist(\"ack\",foo_s,edit)":0.3333333},
{
"id":"2",
"strdist(\"ack\",foo_s,edit)":0.3333333}]
}}
hossman@frisbee:~$ curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/collection1/update?commit=true' --data-binary '[{"id":"3"}]'
{"responseHeader":{"status":0,"QTime":329}}
hossman@frisbee:~$ curl 'http://localhost:8983/solr/collection1/select?q=*:*&indent=true&wt=json&fl=id,strdist("ack",foo_s,edit)'
... ERROR!
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.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:254)
at org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:172)
{noformat}
----
A quick glance suggests that hte root cause is StringDistanceFunction.getValues's anonymous inner subclass of FloatDocValues (aka: StringDistanceFunction$1). Either str1DV.strVal or str1DV.strVal can return null (in which case both of their exists() methods should have returned false, but i haven't verified that) and they do in fact return null when dealing with string fields that may not always have a value.
for the particular example shown above, adding an exists() impl to StringDistanceFunction$1 should prevent ValueSourceAugmenter from ever calling floatVal().
But the question remains as to what floatVal() _should_ return if/when it is called in this situation? Infinity? NaN? 0.0F?
> strdist() causes NPE if doc is missing field
> --------------------------------------------
>
> Key: SOLR-6540
> URL: https://issues.apache.org/jira/browse/SOLR-6540
> Project: Solr
> Issue Type: Bug
> Reporter: Hoss Man
>
> If you try to use the strdist function on a field which is missing in some docs, you'll get a NullPointerException
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org