'POSTs a file to the Solr ExtractingRequestHandler so rich content can
be processed using Apache Tika. See the Solr wiki for details:
http://wiki.apache.org/solr/ExtractingRequestHandler
The ExtractingRequestHandler has a very simple model: it extracts
contents and metadata from the uploaded file and inserts it directly
into the index. This is rarely useful as it allows no way to store
additional data or otherwise customize the record. Instead, by default
we\'ll use the extract-only mode to extract the data without indexing it
so the caller has the opportunity to process it as appropriate; call
with ``extractOnly=False`` if you want to insert with no additional
processing.
Returns None if metadata cannot be extracted; otherwise returns a
dictionary containing at least two keys:
:contents:
Extracted full-text content, if applicable
:metadata:
key:value pairs of text strings'

def extract(self, file_obj, extractOnly=True, handler=u'update/extract', **kwargs):

    if (not hasattr(file_obj, u'name')):
        raise ValueError(u'extract()    requires    file-like    objects    which    have    a    defined    name    property')
    params = {u'extractOnly': (u'true' if extractOnly else u'false'), u'lowernames': u'true', u'wt': u'json'}
    params.update(kwargs)
    try:
        resp = self._send_request(u'post', handler, body=params, files={u'file': (file_obj.name, file_obj)})
    except (IOError, SolrError) as err:
        self.log.error(u'Failed    to    extract    document    metadata:    %s', err, exc_info=True)
        raise
    try:
        data = json.loads(resp)
    except ValueError as err:
        self.log.error(u'Failed    to    load    JSON    response:    %s', err, exc_info=True)
        raise
    data[u'contents'] = data.pop(file_obj.name, None)
    data[u'metadata'] = metadata = {}
    raw_metadata = data.pop((u'%s_metadata' % file_obj.name), None)
    if raw_metadata:
        while raw_metadata:
            metadata[raw_metadata.pop()] = raw_metadata.pop()
    return data
