fixed json search, quotes, auto-facets, urls etc. for

yacyinteractive.html
pull/1/head
Michael Peter Christen 12 years ago
parent 1db23e9eac
commit d3508fa8ff

@ -186,7 +186,7 @@ public class select {
if (connector == null) return null;
// do the solr request, generate facets if we use a special YaCy format
SolrParams params = post.toSolrParams(responseWriter instanceof JsonResponseWriter ? new YaCySchema[]{YaCySchema.host_s, YaCySchema.url_file_ext_s, YaCySchema.url_protocol_s} : null);
SolrParams params = post.toSolrParams(/*responseWriter instanceof JsonResponseWriter ? new YaCySchema[]{YaCySchema.host_s, YaCySchema.url_file_ext_s, YaCySchema.url_protocol_s} :*/ null);
SolrQueryRequest req = connector.request(params);
SolrQueryResponse response = null;
Exception e = null;

@ -37,10 +37,9 @@
<script type="text/javascript">
//<![CDATA[
//document.write("\<a id=\"rsslink\" href=\"yacysearch.rss?" + window.location.search.substring(1) + "\"\>")
document.write("\<a id=\"rsslink\" href=\"/solr/select?hl=false&wt=opensearch&facet=true&facet.mincount=1&facet.field=url_file_ext_s&start=0&rows=10&query=" + window.location.search.substring(1) + "\"\>")
document.write("\<a id=\"rsslink\" href=\"/solr/select?hl=false&wt=opensearch&facet=true&facet.mincount=1&facet.field=url_file_ext_s&start=0&rows=10&query=" + window.location.search.substring(1) + "\"\><img src=\"env/grafics/api.png\" width=\"60\" height=\"40\" alt=\"API\" /></a>");
//]]>
</script>
<img src="env/grafics/api.png" width="60" height="40" alt="API" /></a>
<span>This search result can also be retrieved as RSS/<a href="http://www.opensearch.org">opensearch</a> output.
The query format is similar to <a href="http://www.loc.gov/standards/sru/">SRU</a>.
Click the API icon to see an example call to the search rss API.
@ -57,8 +56,6 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
<fieldset class="yacys">
<input type="hidden" name="maximumRecords" value="#[maximumRecords]#" />
<input type="hidden" name="startRecord" value="#[startRecord]#" />
<input type="hidden" name="verify", value="false" />
<input type="hidden" name="resource", value="local" />
<input type="hidden" name="contentdom", value="all" />
<input id="search" class="searchinput" name="query" type="text" value="#[query]#" size="40" maxlength="80" onFocus="this.select()" />
#(allowrealtime)#

@ -223,7 +223,7 @@ public class JsonResponseWriter implements QueryResponseWriter {
NamedList<Integer> authors = facetFields == null ? null : (NamedList<Integer>) facetFields.get(YaCySchema.author_sxt.getSolrFieldName());
if (domains != null) {
writer.write("{\"facetname\":\"domains\",\"displayname\":\"Domains\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[".toCharArray());
writer.write("{\"facetname\":\"domains\",\"displayname\":\"Domains\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray());
for (int i = 0; i < domains.size(); i++) {
facetEntry(writer, "site", domains.getName(i), Integer.toString(domains.getVal(i)));
if (i < domains.size() - 1) writer.write(',');
@ -232,7 +232,7 @@ public class JsonResponseWriter implements QueryResponseWriter {
writer.write("]},\n".toCharArray());
}
if (filetypes != null) {
writer.write("{\"facetname\":\"filetypes\",\"displayname\":\"Filetypes\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[".toCharArray());
writer.write("{\"facetname\":\"filetypes\",\"displayname\":\"Filetypes\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray());
List<Map.Entry<String, Integer>> l = new ArrayList<Map.Entry<String,Integer>>();
for (Map.Entry<String, Integer> e: filetypes) {
if (e.getKey().length() <= 6) l.add(e);
@ -247,7 +247,7 @@ public class JsonResponseWriter implements QueryResponseWriter {
writer.write("]},\n".toCharArray());
}
if (protocols != null) {
writer.write("{\"facetname\":\"protocols\",\"displayname\":\"Protocol\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[".toCharArray());
writer.write("{\"facetname\":\"protocols\",\"displayname\":\"Protocol\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray());
for (int i = 0; i < protocols.size(); i++) {
facetEntry(writer, "protocol", protocols.getName(i), Integer.toString(protocols.getVal(i)));
if (i < protocols.size() - 1) writer.write(',');
@ -256,7 +256,7 @@ public class JsonResponseWriter implements QueryResponseWriter {
writer.write("]},\n".toCharArray());
}
if (authors != null) {
writer.write("{\"facetname\":\"authors\",\"displayname\":\"Authors\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[".toCharArray());
writer.write("{\"facetname\":\"authors\",\"displayname\":\"Authors\",\"type\":\"String\",\"min\":\"0\",\"max\":\"0\",\"mean\":\"0\",\"elements\":[\n".toCharArray());
for (int i = 0; i < authors.size(); i++) {
facetEntry(writer, "author", authors.getName(i), Integer.toString(authors.getVal(i)));
if (i < authors.size() - 1) writer.write(',');

@ -126,6 +126,13 @@ public class QueryModifier {
}
}
// check the number of quotes in the string; if there is only one double-quote, add another one. this will prevent error messages in
int p = querystring.indexOf('"');
if (p >= 0) {
int q = querystring.indexOf('"', p + 1);
if (q < 0) querystring += '"';
}
return querystring.trim();
}

@ -698,6 +698,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// <key1>=<value1>'&'<key2>=<value2>'&'<key3>=<value3>
// the calling function must strip off a possible leading '?' char
if (argsString.isEmpty()) return 0;
argsString = argsString.replaceAll("&quot;", "%22");
argsString = argsString + "&"; // for technical reasons
int sep;
int eqp;

@ -522,7 +522,7 @@ public class serverObjects implements Serializable, Cloneable {
if (facets != null && facets.length > 0) {
this.remove("facet");
this.put("facet", "true");
for (int i = 0; i < facets.length; i++) this.put("facet.field", facets[i].getSolrFieldName());
for (int i = 0; i < facets.length; i++) this.add("facet.field", facets[i].getSolrFieldName());
}
return this.map;
}

Loading…
Cancel
Save