gsa results shall have only one title in metadata and that should be the

visible title in the <title>-tag
pull/1/head
Michael Peter Christen 12 years ago
parent ae6feb5610
commit b7ac1da6a3

@ -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)) {

@ -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) {

Loading…
Cancel
Save