Permalink
Browse files

fix exception on URIMetadataNote instantiation with corrected id hash on

host_id_s. Use Solr setField instead of addField to prevent
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
	at net.yacy.kelondro.data.meta.URIMetadataNode.hosthash(URIMetadataNode.java:247)
	at net.yacy.search.query.SearchEvent.addNodes(SearchEvent.java:966)
	at net.yacy.peers.Protocol.solrQuery(Protocol.java:1242)
	at net.yacy.peers.RemoteSearch$2.run(RemoteSearch.java:349)
  • Loading branch information...
reger24 committed Jan 4, 2017
1 parent b55cf16 commit eedee6eabb6ed6ce73499a4ba19cc47eb689f1f3
Showing with 3 additions and 3 deletions.
  1. +3 −3 source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -183,7 +183,7 @@ public URIMetadataNode(final Properties prop, String collection) throws Malforme
public URIMetadataNode(final SolrDocument doc) throws MalformedURLException {
super();
for (String name : doc.getFieldNames()) {
this.addField(name, doc.getFieldValue(name));
this.setField(name, doc.getFieldValue(name));
}
/* score shall contain the YaCy score, getFieldValue("score") moved to
* SearchEvent.addNodes() where the YaCy ranking for nodes is calculated
@@ -196,12 +196,12 @@ public URIMetadataNode(final SolrDocument doc) throws MalformedURLException {
if (!hashstr.isEmpty()) { // remote id might not correspond in all cases
final String myhash = ASCII.String(this.url.hash());
if (!hashstr.equals(myhash)) {
this.addField(CollectionSchema.id.getSolrFieldName(), myhash);
this.setField(CollectionSchema.id.getSolrFieldName(), myhash);
ConcurrentLog.fine("URIMetadataNode", "updated document.ID of " + urlRaw + " from " + hashstr + " to " + myhash);
// ususally the hosthash matches but just to be on the safe site
final String hostidstr = getString(CollectionSchema.host_id_s); // id or empty string
if (!hostidstr.isEmpty() && !hostidstr.equals(this.url.hosthash())) {
this.addField(CollectionSchema.host_id_s.getSolrFieldName(), this.url.hosthash());
this.setField(CollectionSchema.host_id_s.getSolrFieldName(), this.url.hosthash());
}
}
}

0 comments on commit eedee6e

Please sign in to comment.