(self, doc)
doc: a dict
doc: a dict
doc : a dict
def add_doc(self, doc):
        """ doc: a dict """
        content = doc['text']
        document = UnprocessedDocument()
        document.fields.append(Field('text', content))

        for k, v in doc.iteritems():
            if k in ['text', 'id']:
                continue
            if type(v) == list:
                for item in v:
                    document.fields.append(Field(k, ensure_unicode(item)))
            else:
                document.fields.append(Field(k, ensure_unicode(v)))
        document.id = str(doc['id'])
        try:
            self.lock.acquire()
            self.dbconn.add(document)
        except errors.IndexerError as e:
            print str(e)
        finally:
            self.lock.release()
def add_doc ( self , doc ) : content = doc [ 'text' ] document = UnprocessedDocument ( ) document . fields . append ( Field ( 'text' , content ) ) for k , v in doc . iteritems ( ) : if k in [ 'text' , 'id' ] : continue if type ( v ) == list : for item in v : document . fields . append ( Field ( k , ensure_unicode ( item ) ) ) else : document . fields . append ( Field ( k , ensure_unicode ( v ) ) ) document . id = str ( doc [ 'id' ] ) try : self . lock . acquire ( ) self . dbconn . add ( document ) except errors . IndexerError as e : print str ( e ) finally : self . lock . release ( )