Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fix: no results with configuration citation reference index switched off - urlcitationindex != null check added to ResultEntry.referencesCount - plus other places where conflicting procedure was used (and urlcitationindex not already checked != null)

regerf301336adf07
diff --git a/htroot/api/webstructure.java b/htroot/api/webstructure.java
index 76fa0cb2c..53f7cbc95 100644
--- a/htroot/api/webstructure.java
+++ b/htroot/api/webstructure.java
@@ -141,10 +141,10 @@ public class webstructure {
IndexCell<CitationReference> citationReferences = sb.index.urlCitation();
ReferenceContainer<CitationReference> citations = null;
// citationReferences.count(urlhash) would give to the number of references good for ranking
- try {
- citations = citationReferences.get(urlhash, null);
- } catch (IOException e) {
- }
+ try {
+ citations = citationReferences != null ? citationReferences.get(urlhash, null) : null;
+ } catch (IOException e) {
+ }
if (citations != null) {
prop.put("citations_count", 1);
prop.put("citations_documents", 1);
diff --git a/htroot/api/yacydoc.java b/htroot/api/yacydoc.java
index 76281b190..038ddc1f5 100644
--- a/htroot/api/yacydoc.java
+++ b/htroot/api/yacydoc.java
@@ -126,7 +126,7 @@ public class yacydoc {
prop.putXML("yacy_referrer_url", (le == null) ? "" : le.url().toNormalform(true));
prop.put("yacy_size", entry.size());
prop.put("yacy_words", entry.wordCount());
- prop.put("yacy_citations", sb.index.urlCitation().count(entry.hash()));
+ prop.put("yacy_citations", sb.index.urlCitation()!= null ? sb.index.urlCitation().count(entry.hash()) : 0);
prop.put("yacy_inbound", entry.llocal());
prop.put("yacy_outbound", entry.lother());
diff --git a/source/net/yacy/search/snippet/ResultEntry.java b/source/net/yacy/search/snippet/ResultEntry.java
index 2388dc095..b9d0c15cc 100644
--- a/source/net/yacy/search/snippet/ResultEntry.java
+++ b/source/net/yacy/search/snippet/ResultEntry.java
@@ -1,221 +1,222 @@
-// ResultEntry.java
-// (C) 2005 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
-// first published 10.10.2005 on http://yacy.net
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// LICENSE
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package net.yacy.search.snippet;
-
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-
-import net.yacy.cora.document.MultiProtocolURI;
-import net.yacy.cora.order.Base64Order;
-import net.yacy.document.Condenser;
-import net.yacy.kelondro.data.meta.DigestURI;
-import net.yacy.kelondro.data.meta.URIMetadataNode;
-import net.yacy.kelondro.data.word.Word;
-import net.yacy.kelondro.data.word.WordReference;
-import net.yacy.kelondro.data.word.WordReferenceRow;
-import net.yacy.kelondro.data.word.WordReferenceVars;
-import net.yacy.kelondro.logging.Log;
-import net.yacy.kelondro.rwi.Reference;
-import net.yacy.kelondro.util.Bitfield;
-import net.yacy.kelondro.util.ByteArray;
-import net.yacy.peers.Seed;
-import net.yacy.peers.SeedDB;
-import net.yacy.search.index.Segment;
-
-
-public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEntry> {
-
- // payload objects
- private final URIMetadataNode urlentry;
- private String alternative_urlstring;
- private String alternative_urlname;
- private final TextSnippet textSnippet;
- private final List<MediaSnippet> mediaSnippets;
- private final Segment indexSegment;
-
- // statistic objects
- public long snippetComputationTime, ranking;
-
- public ResultEntry(final URIMetadataNode urlentry,
- final Segment indexSegment,
- SeedDB peers,
- final TextSnippet textSnippet,
- final List<MediaSnippet> mediaSnippets,
- final long snippetComputationTime) {
- this.urlentry = urlentry;
- this.indexSegment = indexSegment;
- this.alternative_urlstring = null;
- this.alternative_urlname = null;
- this.textSnippet = textSnippet;
- this.mediaSnippets = mediaSnippets;
- this.snippetComputationTime = snippetComputationTime;
- final String host = urlentry.url().getHost();
- if (host != null && host.endsWith(".yacyh")) {
- // translate host into current IP
- int p = host.indexOf('.');
- final String hash = Seed.hexHash2b64Hash(host.substring(p + 1, host.length() - 6));
- final Seed seed = peers.getConnected(hash);
- final String path = urlentry.url().getFile();
- String address = null;
- if ((seed == null) || ((address = seed.getPublicAddress()) == null)) {
- // seed is not known from here
- try {
- indexSegment.termIndex().remove(
- Word.words2hashesHandles(Condenser.getWords(
- ("yacyshare " +
- path.replace('?', ' ') +
- " " +
- urlentry.dc_title()), null).keySet()),
- urlentry.hash());
- } catch (IOException e) {
- Log.logException(e);
- }
- indexSegment.fulltext().remove(urlentry.hash()); // clean up
- throw new RuntimeException("index void");
- }
- this.alternative_urlstring = "http://" + address + "/" + host.substring(0, p) + path;
- this.alternative_urlname = "http://share." + seed.getName() + ".yacy" + path;
- if ((p = this.alternative_urlname.indexOf('?')) > 0) this.alternative_urlname = this.alternative_urlname.substring(0, p);
- }
- }
- private int hashCache = Integer.MIN_VALUE; // if this is used in a compare method many times, a cache is useful
- @Override
- public int hashCode() {
- if (this.hashCache == Integer.MIN_VALUE) {
- this.hashCache = ByteArray.hashCode(this.urlentry.hash());
- }
- return this.hashCache;
- }
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (!(obj instanceof ResultEntry)) return false;
- ResultEntry other = (ResultEntry) obj;
- return Base64Order.enhancedCoder.equal(this.urlentry.hash(), other.urlentry.hash());
- }
- public byte[] hash() {
- return this.urlentry.hash();
- }
- public DigestURI url() {
- return this.urlentry.url();
- }
- public Bitfield flags() {
- return this.urlentry.flags();
- }
- public String urlstring() {
- return (this.alternative_urlstring == null) ? this.urlentry.url().toNormalform(true) : this.alternative_urlstring;
- }
- public String urlname() {
- return (this.alternative_urlname == null) ? MultiProtocolURI.unescape(this.urlentry.url().toNormalform(true)) : this.alternative_urlname;
- }
- public String title() {
- return this.urlentry.dc_title();
- }
- public String publisher() {
- // dc:publisher
- return this.urlentry.dc_publisher();
- }
- public String creator() {
- // dc:creator, the author
- return this.urlentry.dc_creator();
- }
- public String subject() {
- // dc:subject, keywords
- return this.urlentry.dc_subject();
- }
- public TextSnippet textSnippet() {
- return this.textSnippet;
- }
- public List<MediaSnippet> mediaSnippets() {
- return this.mediaSnippets;
- }
- public Date modified() {
- return this.urlentry.moddate();
- }
- public int filesize() {
- return this.urlentry.size();
- }
- public int referencesCount() {
- return this.indexSegment.urlCitation().count(this.urlentry.hash());
- }
- public int llocal() {
- return this.urlentry.llocal();
- }
- public int lother() {
- return this.urlentry.lother();
- }
- public int limage() {
- return this.urlentry.limage();
- }
- public int laudio() {
- return this.urlentry.laudio();
- }
- public int lvideo() {
- return this.urlentry.lvideo();
- }
- public int lapp() {
- return this.urlentry.lapp();
- }
- public double lat() {
- return this.urlentry.lat();
- }
- public double lon() {
- return this.urlentry.lon();
- }
- public WordReference word() {
- final Reference word = this.urlentry.word();
- if (word == null) return null;
- if (word instanceof WordReferenceVars) return (WordReferenceVars) word;
- if (word instanceof WordReferenceRow) return (WordReferenceRow) word;
- assert word instanceof WordReferenceRow || word instanceof WordReferenceVars : word == null ? "word = null" : "type = " + word.getClass().getCanonicalName();
- return null;
- }
- public boolean hasTextSnippet() {
- return (this.textSnippet != null) && (!this.textSnippet.getErrorCode().fail());
- }
- public boolean hasMediaSnippets() {
- return (this.mediaSnippets != null) && (!this.mediaSnippets.isEmpty());
- }
- public String resource() {
- // generate transport resource
- if ((this.textSnippet == null) || (!this.textSnippet.exists())) {
- return this.urlentry.toString();
- }
- return this.urlentry.toString(this.textSnippet.getLineRaw());
- }
- @Override
- public int compareTo(ResultEntry o) {
- return Base64Order.enhancedCoder.compare(this.urlentry.hash(), o.urlentry.hash());
- }
- @Override
- public int compare(ResultEntry o1, ResultEntry o2) {
- return Base64Order.enhancedCoder.compare(o1.urlentry.hash(), o2.urlentry.hash());
- }
-}
+// ResultEntry.java
+// (C) 2005 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// first published 10.10.2005 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate$
+// $LastChangedRevision$
+// $LastChangedBy$
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package net.yacy.search.snippet;
+
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import net.yacy.cora.document.MultiProtocolURI;
+import net.yacy.cora.order.Base64Order;
+import net.yacy.document.Condenser;
+import net.yacy.kelondro.data.meta.DigestURI;
+import net.yacy.kelondro.data.meta.URIMetadataNode;
+import net.yacy.kelondro.data.word.Word;
+import net.yacy.kelondro.data.word.WordReference;
+import net.yacy.kelondro.data.word.WordReferenceRow;
+import net.yacy.kelondro.data.word.WordReferenceVars;
+import net.yacy.kelondro.logging.Log;
+import net.yacy.kelondro.rwi.Reference;
+import net.yacy.kelondro.util.Bitfield;
+import net.yacy.kelondro.util.ByteArray;
+import net.yacy.peers.Seed;
+import net.yacy.peers.SeedDB;
+import net.yacy.search.index.Segment;
+
+
+public class ResultEntry implements Comparable<ResultEntry>, Comparator<ResultEntry> {
+
+ // payload objects
+ private final URIMetadataNode urlentry;
+ private String alternative_urlstring;
+ private String alternative_urlname;
+ private final TextSnippet textSnippet;
+ private final List<MediaSnippet> mediaSnippets;
+ private final Segment indexSegment;
+
+ // statistic objects
+ public long snippetComputationTime, ranking;
+
+ public ResultEntry(final URIMetadataNode urlentry,
+ final Segment indexSegment,
+ SeedDB peers,
+ final TextSnippet textSnippet,
+ final List<MediaSnippet> mediaSnippets,
+ final long snippetComputationTime) {
+ this.urlentry = urlentry;
+ this.indexSegment = indexSegment;
+ this.alternative_urlstring = null;
+ this.alternative_urlname = null;
+ this.textSnippet = textSnippet;
+ this.mediaSnippets = mediaSnippets;
+ this.snippetComputationTime = snippetComputationTime;
+ final String host = urlentry.url().getHost();
+ if (host != null && host.endsWith(".yacyh")) {
+ // translate host into current IP
+ int p = host.indexOf('.');
+ final String hash = Seed.hexHash2b64Hash(host.substring(p + 1, host.length() - 6));
+ final Seed seed = peers.getConnected(hash);
+ final String path = urlentry.url().getFile();
+ String address = null;
+ if ((seed == null) || ((address = seed.getPublicAddress()) == null)) {
+ // seed is not known from here
+ try {
+ indexSegment.termIndex().remove(
+ Word.words2hashesHandles(Condenser.getWords(
+ ("yacyshare " +
+ path.replace('?', ' ') +
+ " " +
+ urlentry.dc_title()), null).keySet()),
+ urlentry.hash());
+ } catch (IOException e) {
+ Log.logException(e);
+ }
+ indexSegment.fulltext().remove(urlentry.hash()); // clean up
+ throw new RuntimeException("index void");
+ }
+ this.alternative_urlstring = "http://" + address + "/" + host.substring(0, p) + path;
+ this.alternative_urlname = "http://share." + seed.getName() + ".yacy" + path;
+ if ((p = this.alternative_urlname.indexOf('?')) > 0) this.alternative_urlname = this.alternative_urlname.substring(0, p);
+ }
+ }
+ private int hashCache = Integer.MIN_VALUE; // if this is used in a compare method many times, a cache is useful
+ @Override
+ public int hashCode() {
+ if (this.hashCache == Integer.MIN_VALUE) {
+ this.hashCache = ByteArray.hashCode(this.urlentry.hash());
+ }
+ return this.hashCache;
+ }
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof ResultEntry)) return false;
+ ResultEntry other = (ResultEntry) obj;
+ return Base64Order.enhancedCoder.equal(this.urlentry.hash(), other.urlentry.hash());
+ }
+ public byte[] hash() {
+ return this.urlentry.hash();
+ }
+ public DigestURI url() {
+ return this.urlentry.url();
+ }
+ public Bitfield flags() {
+ return this.urlentry.flags();
+ }
+ public String urlstring() {
+ return (this.alternative_urlstring == null) ? this.urlentry.url().toNormalform(true) : this.alternative_urlstring;
+ }
+ public String urlname() {
+ return (this.alternative_urlname == null) ? MultiProtocolURI.unescape(this.urlentry.url().toNormalform(true)) : this.alternative_urlname;
+ }
+ public String title() {
+ return this.urlentry.dc_title();
+ }
+ public String publisher() {
+ // dc:publisher
+ return this.urlentry.dc_publisher();
+ }
+ public String creator() {
+ // dc:creator, the author
+ return this.urlentry.dc_creator();
+ }
+ public String subject() {
+ // dc:subject, keywords
+ return this.urlentry.dc_subject();
+ }
+ public TextSnippet textSnippet() {
+ return this.textSnippet;
+ }
+ public List<MediaSnippet> mediaSnippets() {
+ return this.mediaSnippets;
+ }
+ public Date modified() {
+ return this.urlentry.moddate();
+ }
+ public int filesize() {
+ return this.urlentry.size();
+ }
+ public int referencesCount() {
+ // urlCitationIndex index might be null (= configuration option)
+ return this.indexSegment.urlCitation() != null ? this.indexSegment.urlCitation().count(this.urlentry.hash()) : 0;
+ }
+ public int llocal() {
+ return this.urlentry.llocal();
+ }
+ public int lother() {
+ return this.urlentry.lother();
+ }
+ public int limage() {
+ return this.urlentry.limage();
+ }
+ public int laudio() {
+ return this.urlentry.laudio();
+ }
+ public int lvideo() {
+ return this.urlentry.lvideo();
+ }
+ public int lapp() {
+ return this.urlentry.lapp();
+ }
+ public double lat() {
+ return this.urlentry.lat();
+ }
+ public double lon() {
+ return this.urlentry.lon();
+ }
+ public WordReference word() {
+ final Reference word = this.urlentry.word();
+ if (word == null) return null;
+ if (word instanceof WordReferenceVars) return (WordReferenceVars) word;
+ if (word instanceof WordReferenceRow) return (WordReferenceRow) word;
+ assert word instanceof WordReferenceRow || word instanceof WordReferenceVars : word == null ? "word = null" : "type = " + word.getClass().getCanonicalName();
+ return null;
+ }
+ public boolean hasTextSnippet() {
+ return (this.textSnippet != null) && (!this.textSnippet.getErrorCode().fail());
+ }
+ public boolean hasMediaSnippets() {
+ return (this.mediaSnippets != null) && (!this.mediaSnippets.isEmpty());
+ }
+ public String resource() {
+ // generate transport resource
+ if ((this.textSnippet == null) || (!this.textSnippet.exists())) {
+ return this.urlentry.toString();
+ }
+ return this.urlentry.toString(this.textSnippet.getLineRaw());
+ }
+ @Override
+ public int compareTo(ResultEntry o) {
+ return Base64Order.enhancedCoder.compare(this.urlentry.hash(), o.urlentry.hash());
+ }
+ @Override
+ public int compare(ResultEntry o1, ResultEntry o2) {
+ return Base64Order.enhancedCoder.compare(o1.urlentry.hash(), o2.urlentry.hash());
+ }
+}