Beispiel #1
0
class CrowdIndexer():
    def __enter__(self):
        self.searcher = CrowdSearcher()
        mkdir = not os.path.exists(settings.lucene_index_dir)
        self.writer = IndexWriter(self.searcher.index,
            self.searcher.analyzer,
            mkdir,
            IndexWriter.MaxFieldLength.UNLIMITED)
        return self

    def addCrowd(self,id,text):
        doc = Document();
        doc.add(Field(CrowdFields.id, id, Field.Store.YES, Field.Index.NOT_ANALYZED))
        doc.add(Field(CrowdFields.text, text, Field.Store.YES, Field.Index.ANALYZED))
        self.writer.updateDocument(Term(CrowdFields.id, id), doc)

    def __exit__(self, type, value, traecback):
        self.writer.close()
Beispiel #2
0
class CrowdIndexer():
    def __enter__(self):
        self.searcher = CrowdSearcher()
        mkdir = not os.path.exists(settings.lucene_index_dir)
        self.writer = IndexWriter(self.searcher.index, self.searcher.analyzer,
                                  mkdir, IndexWriter.MaxFieldLength.UNLIMITED)
        return self

    def addCrowd(self, id, text):
        doc = Document()
        doc.add(
            Field(CrowdFields.id, id, Field.Store.YES,
                  Field.Index.NOT_ANALYZED))
        doc.add(
            Field(CrowdFields.text, text, Field.Store.YES,
                  Field.Index.ANALYZED))
        self.writer.updateDocument(Term(CrowdFields.id, id), doc)

    def __exit__(self, type, value, traecback):
        self.writer.close()