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: dar...@ontrenet.com [mailto:dar...@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 > mbecca...@paulsmiths.edu > > >