Permalink
Browse files

Add consistency check for related index fields upon load and save of

index schema.
To assemble the original link url for out-/inboundlinks, icons and pictures
the *_protocol_sxt and *_urlstub_sxt is needed (due to the used data-reduced
storage methode). Auto-enable *_protocol_sxt if *_urlstub_sxt is enabled.
to be able to correctly assemble the original link url.
  • Loading branch information...
reger24 committed Jan 27, 2017
1 parent 68afe90 commit 1f497ccad54de1e366577f28cbb4ce8230b5566d
Showing with 33 additions and 0 deletions.
  1. +33 −0 source/net/yacy/search/schema/CollectionConfiguration.java
@@ -150,6 +150,38 @@ public CollectionConfiguration(final File configurationFile, final boolean lazy)
ConcurrentLog.warn("SolrCollectionWriter", " solr schema file " + configurationFile.getAbsolutePath() + " is missing declaration for '" + field.name() + "'");
}
}
checkFieldRelationConsistency();
}
/**
* Check and update schema configuration with required related fields.
* If a specific field is enabled, there might be a other field internal
* processes rely on. Enable these required fields.
* For example, the outboundlinks are split into protocol and url part. The
* correct original url can only be assembled if both fields are available (protocol + url = originalUrl)
*/
private void checkFieldRelationConsistency() {
Entry e;
// for correct assembly of outboundlinks outboundlinks_protocol_sxt + outboundlinks_urlstub_sxt is needed
if (this.contains(CollectionSchema.outboundlinks_urlstub_sxt) && !this.contains(CollectionSchema.outboundlinks_protocol_sxt)) {
e = new Entry(CollectionSchema.outboundlinks_protocol_sxt.name(), CollectionSchema.outboundlinks_protocol_sxt.getSolrFieldName(), true);
this.put(CollectionSchema.outboundlinks_protocol_sxt.name(), e);
}
// for correct assembly of inboundlinks inboundlinks_protocol_sxt + inboundlinks_urlstub_sxt is needed
if (this.contains(CollectionSchema.inboundlinks_urlstub_sxt) && !this.contains(CollectionSchema.inboundlinks_protocol_sxt)) {
e = new Entry(CollectionSchema.inboundlinks_protocol_sxt.name(), CollectionSchema.inboundlinks_protocol_sxt.getSolrFieldName(), true);
this.put(CollectionSchema.inboundlinks_protocol_sxt.name(), e);
}
// for correct assembly of icon url icons_protocol_sxt + icons_urlstub_sxt is needed
if (this.contains(CollectionSchema.icons_urlstub_sxt) && !this.contains(CollectionSchema.icons_protocol_sxt)) {
e = new Entry(CollectionSchema.icons_protocol_sxt.name(), CollectionSchema.icons_protocol_sxt.getSolrFieldName(), true);
this.put(CollectionSchema.icons_protocol_sxt.name(), e);
}
// for correct assembly of image url images_protocol_sxt + images_urlstub_sxt is needed
if (this.contains(CollectionSchema.images_urlstub_sxt) && !this.contains(CollectionSchema.images_protocol_sxt)) {
e = new Entry(CollectionSchema.images_protocol_sxt.name(), CollectionSchema.images_protocol_sxt.getSolrFieldName(), true);
this.put(CollectionSchema.images_protocol_sxt.name(), e);
}
}
public String[] allFields() {
@@ -183,6 +215,7 @@ public Ranking getRanking(final String name) {
*/
@Override
public void commit() throws IOException {
checkFieldRelationConsistency(); // in case of changes, check related fields are enabled before save
try {
super.commit();
// make sure the enum SolrField.SolrFieldName is current

0 comments on commit 1f497cc

Please sign in to comment.