Skip to content

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

gsa results shall have only one title in metadata and that should be the visible title in the <title>-tag

Michael Peter Christenb7ac1da6a328
diff --git a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java
index 9db3c7874..d71f94455 100644
--- a/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java
+++ b/source/net/yacy/cora/federate/solr/responsewriter/GSAResponseWriter.java
@@ -219,6 +219,7 @@ public class GSAResponseWriter implements QueryResponseWriter {
List<String> texts = new ArrayList<String>();
String description = "";
int size = 0;
+ boolean title_written = false; // the solr index may contain several; we take only the first which should be the visible tag in <title></title>
for (int j = 0; j < fieldc; j++) {
Fieldable value = fields.get(j);
String fieldName = value.name();
@@ -240,9 +241,10 @@ public class GSAResponseWriter implements QueryResponseWriter {
OpensearchResponseWriter.solitaireTag(writer, GSAToken.UE.name(), value.stringValue());
continue;
}
- if (YaCySchema.title.getSolrFieldName().equals(fieldName)) {
+ if (YaCySchema.title.getSolrFieldName().equals(fieldName) && !title_written) {
OpensearchResponseWriter.solitaireTag(writer, GSAToken.T.name(), highlight(value.stringValue(), query));
texts.add(value.stringValue());
+ title_written = true;
continue;
}
if (YaCySchema.description.getSolrFieldName().equals(fieldName)) {
diff --git a/source/net/yacy/document/parser/html/ContentScraper.java b/source/net/yacy/document/parser/html/ContentScraper.java
index f6776ae71..5c724c191 100644
--- a/source/net/yacy/document/parser/html/ContentScraper.java
+++ b/source/net/yacy/document/parser/html/ContentScraper.java
@@ -32,7 +32,6 @@ import java.io.Writer;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -128,7 +127,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
private final Map<MultiProtocolURI, EmbedEntry> embeds; // urlhash/embed relation
private final Map<MultiProtocolURI, ImageEntry> images; // urlhash/image relation
private final Map<String, String> metas;
- private Collection<String> titles;
+ private LinkedHashSet<String> titles;
//private String headline;
private List<String>[] headlines;
private final ClusteredScoreMap<String> bold, italic, underline;
@@ -568,10 +567,7 @@ public class ContentScraper extends AbstractScraper implements Scraper {
// some documents have a title tag as meta tag
String s = this.metas.get("title");
if (s != null && s.length() > 0) {
- LinkedHashSet<String> t = new LinkedHashSet<String>();
- t.add(s);
- t.addAll(this.titles);
- this.titles = t;
+ this.titles.add(s);
}
if (this.titles.size() == 0) {