diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java index 63074af3b..f26bc9b60 100644 --- a/source/net/yacy/search/index/Fulltext.java +++ b/source/net/yacy/search/index/Fulltext.java @@ -41,7 +41,6 @@ import net.yacy.cora.services.federated.solr.SolrConnector; import net.yacy.cora.sorting.ConcurrentScoreMap; import net.yacy.cora.sorting.ScoreMap; import net.yacy.cora.storage.HandleSet; -import net.yacy.cora.util.SpaceExceededException; import net.yacy.document.parser.html.CharacterCoding; import net.yacy.kelondro.data.meta.DigestURI; import net.yacy.kelondro.data.meta.URIMetadata; @@ -61,6 +60,7 @@ import org.apache.lucene.util.Version; import org.apache.solr.client.solrj.util.ClientUtils; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; +import org.apache.solr.common.SolrInputDocument; public final class Fulltext implements Iterable { @@ -257,32 +257,20 @@ public final class Fulltext implements Iterable { return null; } + public void putDocument(final SolrInputDocument doc) throws IOException { + if (!this.connectedSolr()) return; + this.solr.add(doc); + } + public void putMetadata(final URIMetadata entry) throws IOException { - if (this.connectedSolr()) { - try { - SolrDocument sd = getSolr().get(ASCII.String(entry.url().hash())); - if (sd == null || !entry.isOlder(new URIMetadataNode(sd))) { - getSolr().add(getSolrScheme().metadata2solr(entry)); - } - } catch (SolrException e) { - throw new IOException(e.getMessage(), e); - } - } else if (this.urlIndexFile != null && entry instanceof URIMetadataRow) { - URIMetadata oldEntry = null; - try { - final Row.Entry oe = this.urlIndexFile.get(entry.hash(), false); - oldEntry = (oe == null) ? null : new URIMetadataRow(oe, null, 0); - } catch (final Throwable e) { - Log.logException(e); - oldEntry = null; - } - if (oldEntry == null || !entry.isOlder(oldEntry)) { - try { - this.urlIndexFile.put(((URIMetadataRow) entry).toRowEntry()); - } catch (final SpaceExceededException e) { - throw new IOException("RowSpaceExceededException in " + this.urlIndexFile.filename() + ": " + e.getMessage()); - } - } + if (!this.connectedSolr()) return; + try { + SolrDocument sd = getSolr().get(ASCII.String(entry.url().hash())); + if (sd == null || !entry.isOlder(new URIMetadataNode(sd))) { + getSolr().add(getSolrScheme().metadata2solr(entry)); + } + } catch (SolrException e) { + throw new IOException(e.getMessage(), e); } this.statsDump = null; if (MemoryControl.shortStatus()) clearCache(); diff --git a/source/net/yacy/search/index/Segment.java b/source/net/yacy/search/index/Segment.java index d9e56f392..d93af2e96 100644 --- a/source/net/yacy/search/index/Segment.java +++ b/source/net/yacy/search/index/Segment.java @@ -39,7 +39,6 @@ import net.yacy.cora.document.MultiProtocolURI; import net.yacy.cora.document.UTF8; import net.yacy.cora.order.ByteOrder; import net.yacy.cora.protocol.ResponseHeader; -import net.yacy.cora.services.federated.solr.SolrDoc; import net.yacy.cora.services.federated.yacy.CacheStrategy; import net.yacy.cora.storage.HandleSet; import net.yacy.cora.util.SpaceExceededException; @@ -405,8 +404,7 @@ public class Segment { // we do not store the data in metadatadb any more if a solr is connected if (this.urlMetadata.connectedSolr()) { try { - SolrDoc solrDoc = this.urlMetadata.getSolrScheme().yacy2solr(id, responseHeader, document, metadata); - this.urlMetadata.getSolr().add(solrDoc); + this.urlMetadata.putDocument(this.urlMetadata.getSolrScheme().yacy2solr(id, responseHeader, document, metadata)); } catch ( final IOException e ) { Log.logWarning("SOLR", "failed to send " + urlNormalform + " to solr: " + e.getMessage()); }