- better date ranking

- more protection against NPE and time travel effects
pull/1/head
Michael Peter Christen 13 years ago
parent ca313e404f
commit 24d2ee3c52

@ -364,11 +364,13 @@ public class yacysearch {
if ( querystring.indexOf("/near", 0) >= 0 ) { if ( querystring.indexOf("/near", 0) >= 0 ) {
querystring = querystring.replace("/near", ""); querystring = querystring.replace("/near", "");
ranking.allZero(); // switch off all attributes
ranking.coeff_worddistance = RankingProfile.COEFF_MAX; ranking.coeff_worddistance = RankingProfile.COEFF_MAX;
modifier.append("/near "); modifier.append("/near ");
} }
if ( querystring.indexOf("/date", 0) >= 0 ) { if ( querystring.indexOf("/date", 0) >= 0 ) {
querystring = querystring.replace("/date", ""); querystring = querystring.replace("/date", "");
ranking.allZero(); // switch off all attributes
ranking.coeff_date = RankingProfile.COEFF_MAX; ranking.coeff_date = RankingProfile.COEFF_MAX;
modifier.append("/date "); modifier.append("/date ");
} }

@ -102,7 +102,9 @@ public class DCEntry extends TreeMap<String, String> {
if (d == null) return null; if (d == null) return null;
if (d.isEmpty()) return null; if (d.isEmpty()) return null;
try { try {
return ISO8601Formatter.FORMATTER.parse(d); Date x = ISO8601Formatter.FORMATTER.parse(d);
Date now = new Date();
return x.after(now) ? now : x;
} catch (ParseException e) { } catch (ParseException e) {
Log.logException(e); Log.logException(e);
return new Date(); return new Date();

@ -130,7 +130,7 @@ public class URIMetadataNode implements URIMetadata {
Date x = (Date) this.doc.getFieldValue(field.name()); Date x = (Date) this.doc.getFieldValue(field.name());
if (x == null) return new Date(0); if (x == null) return new Date(0);
Date now = new Date(); Date now = new Date();
return (x.after(now)) ? now : x; return x.after(now) ? now : x;
} }
private String getString(YaCySchema field) { private String getString(YaCySchema field) {

@ -1063,12 +1063,8 @@ public final class Protocol
final List<ReferenceContainer<WordReference>> container = new ArrayList<ReferenceContainer<WordReference>>(wordhashes.size()); final List<ReferenceContainer<WordReference>> container = new ArrayList<ReferenceContainer<WordReference>>(wordhashes.size());
for (byte[] hash: wordhashes) { for (byte[] hash: wordhashes) {
try { try {
container.add(ReferenceContainer.emptyContainer( container.add(ReferenceContainer.emptyContainer(Segment.wordReferenceFactory, hash, count));
Segment.wordReferenceFactory, } catch (SpaceExceededException e) {} // throws SpaceExceededException
hash,
count));
} catch (SpaceExceededException e) {
} // throws SpaceExceededException
} }
int term = count; int term = count;
@ -1090,11 +1086,10 @@ public final class Protocol
Network.log.logInfo("remote search (solr): filtered blacklisted url " + urlEntry.url() + " from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName()))); Network.log.logInfo("remote search (solr): filtered blacklisted url " + urlEntry.url() + " from " + (target == null ? "shard" : ("peer " + target.hash + ":" + target.getName())));
} }
} }
continue; // block with backlist continue; // block with blacklist
} }
final String urlRejectReason = final String urlRejectReason = Switchboard.getSwitchboard().crawlStacker.urlInAcceptedDomain(urlEntry.url());
Switchboard.getSwitchboard().crawlStacker.urlInAcceptedDomain(urlEntry.url());
if ( urlRejectReason != null ) { if ( urlRejectReason != null ) {
if ( Network.log.isInfo() ) { if ( Network.log.isInfo() ) {
if (localsearch) { if (localsearch) {

@ -175,12 +175,14 @@ public class SolrConfiguration extends ConfigurationSet implements Serializable
public Date getDate(SolrInputDocument doc, final YaCySchema key) { public Date getDate(SolrInputDocument doc, final YaCySchema key) {
Date x = (Date) doc.getFieldValue(key.name()); Date x = (Date) doc.getFieldValue(key.name());
return (x == null) ? new Date(0) : x; Date now = new Date();
return (x == null) ? new Date(0) : x.after(now) ? now : x;
} }
public Date getDate(SolrDocument doc, final YaCySchema key) { public Date getDate(SolrDocument doc, final YaCySchema key) {
Date x = (Date) doc.getFieldValue(key.name()); Date x = doc == null ? null : (Date) doc.getFieldValue(key.name());
return (x == null) ? new Date(0) : x; Date now = new Date();
return (x == null) ? new Date(0) : x.after(now) ? now : x;
} }
/** /**

@ -195,6 +195,46 @@ public class RankingProfile {
return (coeff.get(attr)).intValue(); return (coeff.get(attr)).intValue();
} }
/**
* set all ranking attributes to zero
* This is usually used when a specific value is set to maximum
*/
public void allZero() {
this.coeff_domlength = 0;
this.coeff_ybr = 0;
this.coeff_date = 0;
this.coeff_wordsintitle = 0;
this.coeff_wordsintext = 0;
this.coeff_phrasesintext = 0;
this.coeff_llocal = 0;
this.coeff_lother = 0;
this.coeff_urllength = 0;
this.coeff_urlcomps = 0;
this.coeff_hitcount = 0;
this.coeff_posintext = 0;
this.coeff_posofphrase = 0;
this.coeff_posinphrase = 0;
this.coeff_authority = 0;
this.coeff_worddistance = 0;
this.coeff_appurl = 0;
this.coeff_app_dc_title = 0;
this.coeff_app_dc_creator = 0;
this.coeff_app_dc_subject = 0;
this.coeff_app_dc_description = 0;
this.coeff_appemph = 0;
this.coeff_catindexof = 0;
this.coeff_cathasimage = 0;
this.coeff_cathasaudio = 0;
this.coeff_cathasvideo = 0;
this.coeff_cathasapp = 0;
this.coeff_termfrequency = 0;
this.coeff_urlcompintoplist = 0;
this.coeff_descrcompintoplist = 0;
this.coeff_prefer = 0;
this.coeff_language = 0;
this.coeff_citation = 0;
}
private String externalStringCache = null; private String externalStringCache = null;
public String toExternalString() { public String toExternalString() {
if (this.externalStringCache != null) return this.externalStringCache; if (this.externalStringCache != null) return this.externalStringCache;

Loading…
Cancel
Save