コード例 #1
0
  public void consume(Collection<proj.zoie.api.DataConsumer.DataEvent<V>> events)
      throws ZoieException {
    if (_writer == null) {
      throw new ZoieException("Internal IndexWriter null, perhaps not started?");
    }

    if (events.size() > 0) {
      for (DataEvent<V> event : events) {
        ZoieIndexable indexable = _interpreter.convertAndInterpret(event.getData());
        if (indexable.isSkip()) continue;

        try {
          _writer.deleteDocuments(new Term(DOCUMENT_ID_FIELD, String.valueOf(indexable.getUID())));
        } catch (IOException e) {
          throw new ZoieException(e.getMessage(), e);
        }

        IndexingReq[] reqs = indexable.buildIndexingReqs();
        for (IndexingReq req : reqs) {
          Analyzer localAnalyzer = req.getAnalyzer();
          Document doc = req.getDocument();
          Field uidField =
              new Field(
                  DOCUMENT_ID_FIELD,
                  String.valueOf(indexable.getUID()),
                  Store.NO,
                  Index.NOT_ANALYZED_NO_NORMS);
          uidField.setOmitTermFreqAndPositions(true);
          doc.add(uidField);
          if (localAnalyzer == null) localAnalyzer = _analyzer;
          try {
            _writer.addDocument(doc, localAnalyzer);
          } catch (IOException e) {
            throw new ZoieException(e.getMessage(), e);
          }
        }
      }

      int numdocs;
      try {
        // for realtime commit is not needed per lucene mailing list
        // _writer.commit();
        numdocs = _writer.numDocs();
      } catch (IOException e) {
        throw new ZoieException(e.getMessage(), e);
      }

      logger.info(
          "flushed "
              + events.size()
              + " events to index, index now contains "
              + numdocs
              + " docs.");
    }
  }
コード例 #2
0
 public boolean isSkip() {
   return _inner.isSkip();
 }
コード例 #3
0
 public long getUID() {
   return _inner.getUID();
 }
コード例 #4
0
 public boolean isDeleted() {
   return _inner.isDeleted();
 }
コード例 #5
0
 @Override
 public IndexingReq[] buildIndexingReqs() {
   return _inner.buildIndexingReqs();
 }