In [10]:
import solr

# create a connection to a solr server
s = solr.Solr('http://localhost:8983/solr')

# add a document to the index
doc = dict(
    id=2,
    title='Lucene in Action',
    author=['Erik Hatcher','Test'],
    )
s.add(doc, commit=True)

#sk@ancud.de


---------------------------------------------------------------------------
SolrException                             Traceback (most recent call last)
<ipython-input-10-3604e0ab671c> in <module>()
     10     author=['Erik Hatcher','Test'],
     11     )
---> 12 s.add(doc, commit=True)
     13 
     14 #sk@ancud.de

/home/stephan/prog/anaconda/lib/python2.7/site-packages/solr/core.pyc in wrapper(self, *args, **kw)
    324         content = function(self, *args, **kw)
    325         if content:
--> 326             return self._update(content, query)
    327         # If there's nothing to do (no content), should we issue a
    328         # commit/optimize if those are requested by the options?

/home/stephan/prog/anaconda/lib/python2.7/site-packages/solr/core.pyc in _update(self, request, query)
    549         selector = '%s/update%s' % (self.path, qs_from_items(query))
    550         try:
--> 551             rsp = self._post(selector, request, self.xmlheaders)
    552             data = rsp.read()
    553         finally:

/home/stephan/prog/anaconda/lib/python2.7/site-packages/solr/core.pyc in _post(self, url, body, headers)
    638             try:
    639                 self.conn.request('POST', url, body.encode('UTF-8'), _headers)
--> 640                 return check_response_status(self.conn.getresponse())
    641             except (socket.error,
    642                     httplib.ImproperConnectionState,

/home/stephan/prog/anaconda/lib/python2.7/site-packages/solr/core.pyc in check_response_status(response)
   1101         except:
   1102             pass
-> 1103         raise ex
   1104     return response
   1105 

SolrException: HTTP code=400, reason=Bad Request

In [7]:
# do a search
response = s.select('*:*')
for hit in response.results:
    print hit['title']


[u'Lucene in Action']

In [ ]: