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 Michael Beccaria <mb...@paulsmiths.edu> on 2009/06/25 16:54:48 UTC

Python Response Bug?

I'm not sure, but I think I ran across some unexpected behavior in the
python response in solr 1.3 (1.3.0 694707 - grantingersoll - 2008-09-12
11:06:47).

I'm running Python 2.5 and using eval to convert the string solr returns
to python data objects.

I have a blank field in my xml file that I am importing labeled
"contacthours". If I make the field a "string" type, the interpreter
doesn't throw an error. If I make the field a "float" type, python
throws an error on the eval function. Here is portion of the output from
solr, with the two differences near the end by the "contacthours"
variable:


Broken (Python didn't like this):
{'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
','assessmentcourseprograminstitutionimprovement':u'The students\u2019
final reports along with the \u201cBiology Externship Completion
Form\u201d, which is completed by externship supervisors, will be used
for this assessment.','contacthourrationale':'Variable hours - no
explanation given','contacthours':,'coursearea':'BIO',


Good (this worked):
{'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
','assessmentcourseprograminstitutionimprovement':u'The students\u2019
final reports along with the \u201cBiology Externship Completion
Form\u201d, which is completed by externship supervisors, will be used
for this assessment.','contacthourrationale':'Variable hours - no
explanation given','contacthours':'','coursearea':'BIO',


Any insights? Is this a bug or am I missing something?

Mike Beccaria 
Systems Librarian 
Head of Digital Initiatives 
Paul Smith's College 
518.327.6376 
mbeccaria@paulsmiths.edu 
 


Re: Python Response Bug?

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Python Response Bug?
: In-Reply-To: <20...@suspectum.octantis.com.au>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/Thread_hijacking



-Hoss


RE: Python Response Bug?

Posted by da...@ontrenet.com.
The problem is what should Solr put for a float that is undefined? There
is no such value. Typically a value anomaly should not exist and so when
data structures break, they reveal these situations. The correct action is
to explore why a non-value is making its way into the index and correct it
before that by applying your own logic to populate the field with a
tangible value.

> Regardless, I think it should return valid JSON so programs don't crash
> when trying to interpret it. I don't think about these things often so
> maybe I'm missing something obvious, but I think putting in an empty
> string is better than putting in nothing and having it break.
>
> My 2 cents.
> Mike
>
>
> -----Original Message-----
> From: darren@ontrenet.com [mailto:darren@ontrenet.com]
> Sent: Thursday, June 25, 2009 11:11 AM
> To: solr-user@lucene.apache.org
> Cc: solr-user@lucene.apache.org
> Subject: Re: Python Response Bug?
>
> The first JSON is invalid as you see because of the missing value.
>
> :, is not valid JSON syntax.
>
> The reason it works for string type is because the empty string '' is a
> valid field value but _nothing_ (the first examepl) is not. There is no
> empty float placeholder that JSON likes. So either it has to be an empty
> string or some legitimate float value.
>
> FAIK, Solr doesn't generate empty numeric values compatible with JSON.
> zero and null are different things.
>
>
>
>> I'm not sure, but I think I ran across some unexpected behavior in the
>> python response in solr 1.3 (1.3.0 694707 - grantingersoll -
> 2008-09-12
>> 11:06:47).
>>
>> I'm running Python 2.5 and using eval to convert the string solr
> returns
>> to python data objects.
>>
>> I have a blank field in my xml file that I am importing labeled
>> "contacthours". If I make the field a "string" type, the interpreter
>> doesn't throw an error. If I make the field a "float" type, python
>> throws an error on the eval function. Here is portion of the output
> from
>> solr, with the two differences near the end by the "contacthours"
>> variable:
>>
>>
>> Broken (Python didn't like this):
>>
> {'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
>>
> ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
>> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
>> final reports along with the \u201cBiology Externship Completion
>> Form\u201d, which is completed by externship supervisors, will be used
>> for this assessment.','contacthourrationale':'Variable hours - no
>> explanation given','contacthours':,'coursearea':'BIO',
>>
>>
>> Good (this worked):
>>
> {'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
>>
> ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
>> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
>> final reports along with the \u201cBiology Externship Completion
>> Form\u201d, which is completed by externship supervisors, will be used
>> for this assessment.','contacthourrationale':'Variable hours - no
>> explanation given','contacthours':'','coursearea':'BIO',
>>
>>
>> Any insights? Is this a bug or am I missing something?
>>
>> Mike Beccaria
>> Systems Librarian
>> Head of Digital Initiatives
>> Paul Smith's College
>> 518.327.6376
>> mbeccaria@paulsmiths.edu
>>
>>
>>
>
>


RE: Python Response Bug?

Posted by Michael Beccaria <mb...@paulsmiths.edu>.
Regardless, I think it should return valid JSON so programs don't crash
when trying to interpret it. I don't think about these things often so
maybe I'm missing something obvious, but I think putting in an empty
string is better than putting in nothing and having it break.

My 2 cents.
Mike


-----Original Message-----
From: darren@ontrenet.com [mailto:darren@ontrenet.com] 
Sent: Thursday, June 25, 2009 11:11 AM
To: solr-user@lucene.apache.org
Cc: solr-user@lucene.apache.org
Subject: Re: Python Response Bug?

The first JSON is invalid as you see because of the missing value.

:, is not valid JSON syntax.

The reason it works for string type is because the empty string '' is a
valid field value but _nothing_ (the first examepl) is not. There is no
empty float placeholder that JSON likes. So either it has to be an empty
string or some legitimate float value.

FAIK, Solr doesn't generate empty numeric values compatible with JSON.
zero and null are different things.



> I'm not sure, but I think I ran across some unexpected behavior in the
> python response in solr 1.3 (1.3.0 694707 - grantingersoll -
2008-09-12
> 11:06:47).
>
> I'm running Python 2.5 and using eval to convert the string solr
returns
> to python data objects.
>
> I have a blank field in my xml file that I am importing labeled
> "contacthours". If I make the field a "string" type, the interpreter
> doesn't throw an error. If I make the field a "float" type, python
> throws an error on the eval function. Here is portion of the output
from
> solr, with the two differences near the end by the "contacthours"
> variable:
>
>
> Broken (Python didn't like this):
>
{'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
>
ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
> final reports along with the \u201cBiology Externship Completion
> Form\u201d, which is completed by externship supervisors, will be used
> for this assessment.','contacthourrationale':'Variable hours - no
> explanation given','contacthours':,'coursearea':'BIO',
>
>
> Good (this worked):
>
{'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
>
ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
> final reports along with the \u201cBiology Externship Completion
> Form\u201d, which is completed by externship supervisors, will be used
> for this assessment.','contacthourrationale':'Variable hours - no
> explanation given','contacthours':'','coursearea':'BIO',
>
>
> Any insights? Is this a bug or am I missing something?
>
> Mike Beccaria
> Systems Librarian
> Head of Digital Initiatives
> Paul Smith's College
> 518.327.6376
> mbeccaria@paulsmiths.edu
>
>
>


Re: Python Response Bug?

Posted by da...@ontrenet.com.
The first JSON is invalid as you see because of the missing value.

:, is not valid JSON syntax.

The reason it works for string type is because the empty string '' is a
valid field value but _nothing_ (the first examepl) is not. There is no
empty float placeholder that JSON likes. So either it has to be an empty
string or some legitimate float value.

FAIK, Solr doesn't generate empty numeric values compatible with JSON.
zero and null are different things.



> I'm not sure, but I think I ran across some unexpected behavior in the
> python response in solr 1.3 (1.3.0 694707 - grantingersoll - 2008-09-12
> 11:06:47).
>
> I'm running Python 2.5 and using eval to convert the string solr returns
> to python data objects.
>
> I have a blank field in my xml file that I am importing labeled
> "contacthours". If I make the field a "string" type, the interpreter
> doesn't throw an error. If I make the field a "float" type, python
> throws an error on the eval function. Here is portion of the output from
> solr, with the two differences near the end by the "contacthours"
> variable:
>
>
> Broken (Python didn't like this):
> {'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
> ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
> final reports along with the \u201cBiology Externship Completion
> Form\u201d, which is completed by externship supervisors, will be used
> for this assessment.','contacthourrationale':'Variable hours - no
> explanation given','contacthours':,'coursearea':'BIO',
>
>
> Good (this worked):
> {'responseHeader':{'status':0,'QTime':0,'params':{'q':'id:"161"','wt':'p
> ython'}},'response':{'numFound':1,'start':0,'docs':[{'approvalpending':'
> ','assessmentcourseprograminstitutionimprovement':u'The students\u2019
> final reports along with the \u201cBiology Externship Completion
> Form\u201d, which is completed by externship supervisors, will be used
> for this assessment.','contacthourrationale':'Variable hours - no
> explanation given','contacthours':'','coursearea':'BIO',
>
>
> Any insights? Is this a bug or am I missing something?
>
> Mike Beccaria
> Systems Librarian
> Head of Digital Initiatives
> Paul Smith's College
> 518.327.6376
> mbeccaria@paulsmiths.edu
>
>
>