Search in sources :

Example 1 with LazyFulltextFieldImpl

use of cz.mzk.recordmanager.server.index.enrich.LazyFulltextFieldImpl in project RecordManager2 by moravianlibrary.

the class SolrServerFacadeImpl method indexLazyFulltext.

private void indexLazyFulltext(Collection<SolrInputDocument> documents, int commitWithinMs) throws SolrServerException {
    for (SolrInputDocument document : documents) {
        boolean carryOn = true;
        while (carryOn) {
            try {
                LazyFulltextFieldImpl fulltext = (LazyFulltextFieldImpl) document.getFieldValue(SolrFieldConstants.FULLTEXT_FIELD);
                document.setField(SolrFieldConstants.FULLTEXT_FIELD, fulltext.getContent());
                server.add(document, commitWithinMs);
                exceptionHandler.ok();
                carryOn = false;
            } catch (SolrException | SolrServerException | IOException ex) {
                carryOn = exceptionHandler.handle(ex, Collections.singletonList(document)) == Action.RETRY;
            } finally {
                // to enable garbage collection
                document.removeField(SolrFieldConstants.FULLTEXT_FIELD);
            }
        }
    }
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) LazyFulltextFieldImpl(cz.mzk.recordmanager.server.index.enrich.LazyFulltextFieldImpl) SolrException(org.apache.solr.common.SolrException)

Aggregations

LazyFulltextFieldImpl (cz.mzk.recordmanager.server.index.enrich.LazyFulltextFieldImpl)1 IOException (java.io.IOException)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 SolrException (org.apache.solr.common.SolrException)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1