diff --git a/source/net/yacy/cora/services/federated/solr/EnhancedXMLResponseWriter.java b/source/net/yacy/cora/services/federated/solr/EnhancedXMLResponseWriter.java index 9b05321f4..62a53d971 100644 --- a/source/net/yacy/cora/services/federated/solr/EnhancedXMLResponseWriter.java +++ b/source/net/yacy/cora/services/federated/solr/EnhancedXMLResponseWriter.java @@ -83,6 +83,7 @@ public class EnhancedXMLResponseWriter implements QueryResponseWriter { } private static void writeProps(final Writer writer, final String name, final NamedList val) throws IOException { + if (val == null) return; int sz = val.size(); if (sz <= 0) startTagClose(writer, "lst", name); else startTagOpen(writer, "lst", name); Object v; @@ -153,7 +154,8 @@ public class EnhancedXMLResponseWriter implements QueryResponseWriter { if (fidx1 + 1 == fidx2) { if (sf.multiValued()) { startTagOpen(writer, "arr", fieldName); - writeField(writer, type, null, value.stringValue()); //sf.write(this, null, f1); + String sv = value.stringValue(); + writeField(writer, type, null, sv); //sf.write(this, null, f1); writer.write(""); } else { writeField(writer, type, value.name(), value.stringValue()); //sf.write(this, f1.name(), f1); @@ -161,7 +163,8 @@ public class EnhancedXMLResponseWriter implements QueryResponseWriter { } else { startTagOpen(writer, "arr", fieldName); for (int i = fidx1; i < fidx2; i++) { - writeField(writer, type, null, fields.get(i).stringValue()); //sf.write(this, null, (Fieldable)this.tlst.get(i)); + String sv = fields.get(i).stringValue(); + writeField(writer, type, null, sv); //sf.write(this, null, (Fieldable)this.tlst.get(i)); } writer.write(""); writer.write(lb); diff --git a/source/net/yacy/cora/services/federated/solr/JsonResponseWriter.java b/source/net/yacy/cora/services/federated/solr/JsonResponseWriter.java index 966a37501..3aecf6528 100644 --- a/source/net/yacy/cora/services/federated/solr/JsonResponseWriter.java +++ b/source/net/yacy/cora/services/federated/solr/JsonResponseWriter.java @@ -109,17 +109,17 @@ public class JsonResponseWriter implements QueryResponseWriter { List fields = doc.getFields(); int fieldc = fields.size(); List texts = new ArrayList(); - String description = ""; + String description = "", title = ""; + StringBuilder path = new StringBuilder(80); for (int j = 0; j < fieldc; j++) { Fieldable value = fields.get(j); String fieldName = value.name(); if (YaCySchema.title.name().equals(fieldName)) { - solitaireTag(writer, "title", value.stringValue()); - texts.add(value.stringValue()); + title = value.stringValue(); + texts.add(title); continue; } if (YaCySchema.sku.name().equals(fieldName)) { - urlhash = value.stringValue(); solitaireTag(writer, "link", value.stringValue()); continue; } @@ -133,14 +133,20 @@ public class JsonResponseWriter implements QueryResponseWriter { solitaireTag(writer, "guid", urlhash); continue; } + if (YaCySchema.host_s.name().equals(fieldName)) { + solitaireTag(writer, "host", value.stringValue()); + continue; + } + if (YaCySchema.url_paths_sxt.name().equals(fieldName)) { + path.append('/').append(value.stringValue()); + continue; + } if (YaCySchema.last_modified.name().equals(fieldName)) { Date d = new Date(Long.parseLong(value.stringValue())); solitaireTag(writer, "pubDate", HeaderFramework.formatRFC1123(d)); - texts.add(value.stringValue()); continue; } if (YaCySchema.size_i.equals(fieldName)) { - urlhash = value.stringValue(); int size = value.stringValue() != null && value.stringValue().length() > 0 ? Integer.parseInt(value.stringValue()) : -1; int sizekb = size / 1024; int sizemb = sizekb / 1024; @@ -161,6 +167,9 @@ public class JsonResponseWriter implements QueryResponseWriter { } } // compute snippet from texts + + solitaireTag(writer, "path", path.toString()); + solitaireTag(writer, "title", title.length() == 0 ? (texts.size() == 0 ? path.toString() : texts.get(0)) : title); List snippet = urlhash == null ? null : snippets.get(urlhash); writer.write("\"description\":\""); writer.write(serverObjects.toJSON(snippet == null || snippet.size() == 0 ? description : snippet.get(0))); writer.write("\"\n}\n"); if (i < responseCount - 1) { diff --git a/source/net/yacy/cora/services/federated/solr/OpensearchResponseWriter.java b/source/net/yacy/cora/services/federated/solr/OpensearchResponseWriter.java index dda1cde93..8658f01d3 100644 --- a/source/net/yacy/cora/services/federated/solr/OpensearchResponseWriter.java +++ b/source/net/yacy/cora/services/federated/solr/OpensearchResponseWriter.java @@ -151,7 +151,7 @@ public class OpensearchResponseWriter implements QueryResponseWriter { List fields = doc.getFields(); int fieldc = fields.size(); List texts = new ArrayList(); - String description = ""; + String description = "", title = ""; for (int j = 0; j < fieldc; j++) { Fieldable value = fields.get(j); String fieldName = value.name(); @@ -170,14 +170,13 @@ public class OpensearchResponseWriter implements QueryResponseWriter { continue; } if (YaCySchema.title.name().equals(fieldName)) { - solitaireTag(writer, RSSMessage.Token.title.name(), value.stringValue()); - texts.add(value.stringValue()); + title = value.stringValue(); + texts.add(title); continue; } if (YaCySchema.last_modified.name().equals(fieldName)) { Date d = new Date(Long.parseLong(value.stringValue())); solitaireTag(writer, RSSMessage.Token.pubDate.name(), HeaderFramework.formatRFC1123(d)); - texts.add(value.stringValue()); continue; } if (YaCySchema.description.name().equals(fieldName)) { @@ -199,6 +198,8 @@ public class OpensearchResponseWriter implements QueryResponseWriter { } } // compute snippet from texts + + solitaireTag(writer, RSSMessage.Token.title.name(), title.length() == 0 ? (texts.size() == 0 ? "" : texts.get(0)) : title); List snippet = urlhash == null ? null : snippets.get(urlhash); String tagname = RSSMessage.Token.description.name(); writer.write("<"); writer.write(tagname); writer.write('>');