mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
- fixed bad search results when searching for empty string
- simplified result handling and page composition in case that nothing was searched git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5807 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
8a24350036
commit
12d81e98eb
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>YaCy '#[clientname]#': Search Page</title>
|
<title>YaCy '#[clientname]#': Search Page</title>
|
||||||
#%env/templates/metas.template%#
|
#%env/templates/metas.template%#
|
||||||
<link rel="alternate" type="application/rss+xml" title="Search for #[input_former]#" href="yacysearch.rss?search=#[input_former]#" />
|
<link rel="alternate" type="application/rss+xml" title="Search for #[former]#" href="yacysearch.rss?search=#[former]#" />
|
||||||
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="opensearchdescription.xml" />
|
<link rel="search" type="application/opensearchdescription+xml" title="YaCy Search on '#[clientname]#'" href="opensearchdescription.xml" />
|
||||||
<script type="text/javascript" src="/js/ajax.js"></script>
|
<script type="text/javascript" src="/js/ajax.js"></script>
|
||||||
<script type="text/javascript" src="/js/xml.js"></script>
|
<script type="text/javascript" src="/js/xml.js"></script>
|
||||||
|
@ -54,30 +54,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
|
||||||
#%env/templates/embeddedheader.template%#
|
#%env/templates/embeddedheader.template%#
|
||||||
#(/display)#
|
#(/display)#
|
||||||
|
|
||||||
#(input)#
|
<form class="search small" action="yacysearch.html" method="get" accept-charset="UTF-8">
|
||||||
::
|
|
||||||
<form class="search small" action="yacysearch.html" method="get" accept-charset="UTF-8">
|
|
||||||
<fieldset class="yacys">
|
|
||||||
<input id="search" name="query" type="text" size="50" maxlength="80" value="#[former]#" onclick="document.getElementById('Enter').value = 'Search'" />
|
|
||||||
<input id="Enter" type="submit" name="Enter" value="Search" />
|
|
||||||
<input type="hidden" name="contentdom" value="#[contentdom]#" />
|
|
||||||
<input type="hidden" name="former" value="#[former]#" />
|
|
||||||
<input type="hidden" name="verify" value="#[verify]#" />
|
|
||||||
<input type="hidden" name="maximumRecords" value="#[count]#" />
|
|
||||||
<input type="hidden" name="startRecord" value="#[offset]#" />
|
|
||||||
<input type="hidden" name="resource" value="#[resource]#" />
|
|
||||||
<input type="hidden" name="urlmaskfilter" value="#[urlmaskfilter]#" />
|
|
||||||
<input type="hidden" name="prefermaskfilter" value="#[prefermaskfilter]#" />
|
|
||||||
<input type="hidden" name="depth" value="#[depth]#" />
|
|
||||||
<input type="hidden" name="cat" value="#[cat]#" />
|
|
||||||
<input type="hidden" name="type" value="#[type]#" />
|
|
||||||
<input type="hidden" name="display" value="#[display]#" />
|
|
||||||
<input type="hidden" name="input" value="#[input]#" />
|
|
||||||
<input type="hidden" name="constraint" value="#[constraint]#" />
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
::
|
|
||||||
<form class="search small" action="yacysearch.html" method="get" accept-charset="UTF-8">
|
|
||||||
<h2>#[promoteSearchPageGreeting]#</h2>
|
<h2>#[promoteSearchPageGreeting]#</h2>
|
||||||
<div class="yacylogo"><a href="#[promoteSearchPageGreeting.homepage]#" class="yacylogo"><img src="#[promoteSearchPageGreeting.smallImage]#" alt="yacysearch" /></a></div>
|
<div class="yacylogo"><a href="#[promoteSearchPageGreeting.homepage]#" class="yacylogo"><img src="#[promoteSearchPageGreeting.smallImage]#" alt="yacysearch" /></a></div>
|
||||||
<fieldset class="yacys">
|
<fieldset class="yacys">
|
||||||
|
@ -95,7 +72,7 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
|
||||||
<input type="radio" id="appl" name="contentdom" value="app"#(contentdomCheckApp)#:: checked="checked"#(/contentdomCheckApp)# />
|
<input type="radio" id="appl" name="contentdom" value="app"#(contentdomCheckApp)#:: checked="checked"#(/contentdomCheckApp)# />
|
||||||
<label for="appl">Applications</label>
|
<label for="appl">Applications</label>
|
||||||
|
|
||||||
<a href="index.html?display=#[display]#&input=#[input]#&searchoptions=1&count=#[count]#&resource=#[resource]#&urlmaskfilter=#[urlmaskfilter]#&prefermaskfilter=#[prefermaskfilter]#&cat=#[cat]#&constraint=#[constraint]#&contentdom=#[contentdom]#&former=#[former]#">more options</a>
|
<a href="index.html?display=#[display]#&searchoptions=1&count=#[count]#&resource=#[resource]#&urlmaskfilter=#[urlmaskfilter]#&prefermaskfilter=#[prefermaskfilter]#&cat=#[cat]#&constraint=#[constraint]#&contentdom=#[contentdom]#&former=#[former]#">more options</a>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="former" value="#[former]#" />
|
<input type="hidden" name="former" value="#[former]#" />
|
||||||
<input type="hidden" name="maximumRecords" value="#[count]#" />
|
<input type="hidden" name="maximumRecords" value="#[count]#" />
|
||||||
|
@ -107,11 +84,9 @@ To see a list of all APIs, please visit the <a href="http://www.yacy-websuche.de
|
||||||
<input type="hidden" name="depth" value="#[depth]#" />
|
<input type="hidden" name="depth" value="#[depth]#" />
|
||||||
<input type="hidden" name="cat" value="#[cat]#" />
|
<input type="hidden" name="cat" value="#[cat]#" />
|
||||||
<input type="hidden" name="display" value="#[display]#" />
|
<input type="hidden" name="display" value="#[display]#" />
|
||||||
<input type="hidden" name="input" value="#[input]#" />
|
|
||||||
<input type="hidden" name="constraint" value="#[constraint]#" />
|
<input type="hidden" name="constraint" value="#[constraint]#" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
#(/input)#
|
|
||||||
|
|
||||||
#(searchagain)#
|
#(searchagain)#
|
||||||
::
|
::
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class yacysearch {
|
||||||
final String browserPopUpPage = sb.getConfig(plasmaSwitchboardConstants.BROWSER_POP_UP_PAGE, "ConfigBasic.html");
|
final String browserPopUpPage = sb.getConfig(plasmaSwitchboardConstants.BROWSER_POP_UP_PAGE, "ConfigBasic.html");
|
||||||
if (browserPopUpPage.startsWith("index") || browserPopUpPage.startsWith("yacysearch")) display = 2;
|
if (browserPopUpPage.startsWith("index") || browserPopUpPage.startsWith("yacysearch")) display = 2;
|
||||||
}
|
}
|
||||||
final int input = (post == null) ? 2 : post.getInt("input", 2);
|
|
||||||
String promoteSearchPageGreeting = env.getConfig(plasmaSwitchboardConstants.GREETING, "");
|
String promoteSearchPageGreeting = env.getConfig(plasmaSwitchboardConstants.GREETING, "");
|
||||||
if (env.getConfigBool(plasmaSwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
|
if (env.getConfigBool(plasmaSwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
|
||||||
final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
|
final String client = header.get(httpRequestHeader.CONNECTION_PROP_CLIENTIP); // the search client who initiated the search
|
||||||
|
@ -87,35 +86,32 @@ public class yacysearch {
|
||||||
final serverObjects prop = new serverObjects();
|
final serverObjects prop = new serverObjects();
|
||||||
|
|
||||||
//final boolean rss = (post == null) ? false : post.get("rss", "false").equals("true");
|
//final boolean rss = (post == null) ? false : post.get("rss", "false").equals("true");
|
||||||
prop.put("input_promoteSearchPageGreeting", promoteSearchPageGreeting);
|
prop.put("promoteSearchPageGreeting", promoteSearchPageGreeting);
|
||||||
prop.put("input_promoteSearchPageGreeting.homepage", sb.getConfig(plasmaSwitchboardConstants.GREETING_HOMEPAGE, ""));
|
prop.put("promoteSearchPageGreeting.homepage", sb.getConfig(plasmaSwitchboardConstants.GREETING_HOMEPAGE, ""));
|
||||||
prop.put("input_promoteSearchPageGreeting.smallImage", sb.getConfig(plasmaSwitchboardConstants.GREETING_SMALL_IMAGE, ""));
|
prop.put("promoteSearchPageGreeting.smallImage", sb.getConfig(plasmaSwitchboardConstants.GREETING_SMALL_IMAGE, ""));
|
||||||
if ((post == null) || (env == null) || (querystring.length() == 0) || (!searchAllowed)) {
|
if ((post == null) || (env == null) || (!searchAllowed)) {
|
||||||
// we create empty entries for template strings
|
// we create empty entries for template strings
|
||||||
prop.put("searchagain", "0");
|
prop.put("searchagain", "0");
|
||||||
prop.put("input", input);
|
|
||||||
prop.put("display", display);
|
prop.put("display", display);
|
||||||
prop.put("input_input", input);
|
prop.put("display", display);
|
||||||
prop.put("input_display", display);
|
|
||||||
prop.put("input_former", "");
|
|
||||||
prop.put("former", "");
|
prop.put("former", "");
|
||||||
prop.put("input_count", "10");
|
prop.put("count", "10");
|
||||||
prop.put("input_offset", "0");
|
prop.put("offset", "0");
|
||||||
prop.put("input_resource", "global");
|
prop.put("resource", "global");
|
||||||
prop.put("input_urlmaskfilter", (post == null) ? ".*" : post.get("urlmaskfilter", ".*"));
|
prop.put("urlmaskfilter", (post == null) ? ".*" : post.get("urlmaskfilter", ".*"));
|
||||||
prop.put("input_prefermaskfilter", (post == null) ? "" : post.get("prefermaskfilter", ""));
|
prop.put("prefermaskfilter", (post == null) ? "" : post.get("prefermaskfilter", ""));
|
||||||
prop.put("input_tenant", (post == null) ? "" : post.get("tenant", ""));
|
prop.put("tenant", (post == null) ? "" : post.get("tenant", ""));
|
||||||
prop.put("input_indexof", "off");
|
prop.put("indexof", "off");
|
||||||
prop.put("input_constraint", "");
|
prop.put("constraint", "");
|
||||||
prop.put("input_cat", "href");
|
prop.put("cat", "href");
|
||||||
prop.put("input_depth", "0");
|
prop.put("depth", "0");
|
||||||
prop.put("input_verify", (post == null) ? "true" : post.get("verify", "true"));
|
prop.put("verify", (post == null) ? "true" : post.get("verify", "true"));
|
||||||
prop.put("input_contentdom", "text");
|
prop.put("contentdom", "text");
|
||||||
prop.put("input_contentdomCheckText", "1");
|
prop.put("contentdomCheckText", "1");
|
||||||
prop.put("input_contentdomCheckAudio", "0");
|
prop.put("contentdomCheckAudio", "0");
|
||||||
prop.put("input_contentdomCheckVideo", "0");
|
prop.put("contentdomCheckVideo", "0");
|
||||||
prop.put("input_contentdomCheckImage", "0");
|
prop.put("contentdomCheckImage", "0");
|
||||||
prop.put("input_contentdomCheckApp", "0");
|
prop.put("contentdomCheckApp", "0");
|
||||||
prop.put("excluded", "0");
|
prop.put("excluded", "0");
|
||||||
prop.put("results", "");
|
prop.put("results", "");
|
||||||
prop.put("resultTable", "0");
|
prop.put("resultTable", "0");
|
||||||
|
@ -497,8 +493,8 @@ public class yacysearch {
|
||||||
prop.put("num-results", "3");
|
prop.put("num-results", "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.put("input_cat", "href");
|
prop.put("cat", "href");
|
||||||
prop.put("input_depth", "0");
|
prop.put("depth", "0");
|
||||||
|
|
||||||
// adding some additional properties needed for the rss feed
|
// adding some additional properties needed for the rss feed
|
||||||
String hostName = (String) header.get("Host", "localhost");
|
String hostName = (String) header.get("Host", "localhost");
|
||||||
|
@ -508,25 +504,23 @@ public class yacysearch {
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.put("searchagain", global ? "1" : "0");
|
prop.put("searchagain", global ? "1" : "0");
|
||||||
prop.put("input", input);
|
|
||||||
prop.put("display", display);
|
prop.put("display", display);
|
||||||
prop.put("input_input", input);
|
prop.put("display", display);
|
||||||
prop.put("input_display", display);
|
prop.putHTML("former", querystring);
|
||||||
prop.putHTML("input_former", querystring);
|
prop.put("count", itemsPerPage);
|
||||||
prop.put("input_count", itemsPerPage);
|
prop.put("offset", offset);
|
||||||
prop.put("input_offset", offset);
|
prop.put("resource", global ? "global" : "local");
|
||||||
prop.put("input_resource", global ? "global" : "local");
|
prop.putHTML("urlmaskfilter", originalUrlMask);
|
||||||
prop.putHTML("input_urlmaskfilter", originalUrlMask);
|
prop.putHTML("prefermaskfilter", prefermask);
|
||||||
prop.putHTML("input_prefermaskfilter", prefermask);
|
prop.put("indexof", (indexof) ? "on" : "off");
|
||||||
prop.put("input_indexof", (indexof) ? "on" : "off");
|
prop.put("constraint", (constraint == null) ? "" : constraint.exportB64());
|
||||||
prop.put("input_constraint", (constraint == null) ? "" : constraint.exportB64());
|
prop.put("verify", (fetchSnippets) ? "true" : "false");
|
||||||
prop.put("input_verify", (fetchSnippets) ? "true" : "false");
|
prop.put("contentdom", (post == null ? "text" : post.get("contentdom", "text")));
|
||||||
prop.put("input_contentdom", (post == null ? "text" : post.get("contentdom", "text")));
|
prop.put("contentdomCheckText", (contentdomCode == plasmaSearchQuery.CONTENTDOM_TEXT) ? "1" : "0");
|
||||||
prop.put("input_contentdomCheckText", (contentdomCode == plasmaSearchQuery.CONTENTDOM_TEXT) ? "1" : "0");
|
prop.put("contentdomCheckAudio", (contentdomCode == plasmaSearchQuery.CONTENTDOM_AUDIO) ? "1" : "0");
|
||||||
prop.put("input_contentdomCheckAudio", (contentdomCode == plasmaSearchQuery.CONTENTDOM_AUDIO) ? "1" : "0");
|
prop.put("contentdomCheckVideo", (contentdomCode == plasmaSearchQuery.CONTENTDOM_VIDEO) ? "1" : "0");
|
||||||
prop.put("input_contentdomCheckVideo", (contentdomCode == plasmaSearchQuery.CONTENTDOM_VIDEO) ? "1" : "0");
|
prop.put("contentdomCheckImage", (contentdomCode == plasmaSearchQuery.CONTENTDOM_IMAGE) ? "1" : "0");
|
||||||
prop.put("input_contentdomCheckImage", (contentdomCode == plasmaSearchQuery.CONTENTDOM_IMAGE) ? "1" : "0");
|
prop.put("contentdomCheckApp", (contentdomCode == plasmaSearchQuery.CONTENTDOM_APP) ? "1" : "0");
|
||||||
prop.put("input_contentdomCheckApp", (contentdomCode == plasmaSearchQuery.CONTENTDOM_APP) ? "1" : "0");
|
|
||||||
|
|
||||||
// for RSS: don't HTML encode some elements
|
// for RSS: don't HTML encode some elements
|
||||||
prop.putXML("rss_query", querystring);
|
prop.putXML("rss_query", querystring);
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
"channels": [{
|
"channels": [{
|
||||||
"title": "YaCy P2P-Search for #[rss_query]#",
|
"title": "YaCy P2P-Search for #[rss_query]#",
|
||||||
"description": "Search for #[rss_query]#",
|
"description": "Search for #[rss_query]#",
|
||||||
"link": "#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[input_resource]#&contentdom=#[input_contentdom]#&verify=#[input_verify]#",
|
"link": "#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[resource]#&contentdom=#[contentdom]#&verify=#[verify]#",
|
||||||
"image": {
|
"image": {
|
||||||
"url": "#[rssYacyImageURL]#",
|
"url": "#[rssYacyImageURL]#",
|
||||||
"title": "Search for #[rss_query]#",
|
"title": "Search for #[rss_query]#",
|
||||||
"link": "#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[input_resource]#&contentdom=#[input_contentdom]#&verify=#[input_verify]#"
|
"link": "#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[resource]#&contentdom=#[contentdom]#&verify=#[verify]#"
|
||||||
},
|
},
|
||||||
"totalResults": "#[num-results_totalcount]#",
|
"totalResults": "#[num-results_totalcount]#",
|
||||||
"startIndex": "#[num-results_offset]#",
|
"startIndex": "#[num-results_offset]#",
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
xmlns:yacy="http://www.yacy.net/"
|
xmlns:yacy="http://www.yacy.net/"
|
||||||
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
|
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
|
||||||
xmlns:atom="http://www.w3.org/2005/Atom">
|
xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<!-- YaCy P2P Web Search - Results; http://yacy.net -->
|
<!-- YaCy Search Engine; http://yacy.net -->
|
||||||
<channel>
|
<channel>
|
||||||
<title>YaCy P2P-Search for #[rss_query]#</title>
|
<title>#[promoteSearchPageGreeting]#</title>
|
||||||
<description>Search for #[rss_query]#</description>
|
<description>Search for #[rss_query]#</description>
|
||||||
<link>#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[input_resource]#&contentdom=#[input_contentdom]#&verify=#[input_verify]#</link>
|
<link>#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[resource]#&contentdom=#[contentdom]#&verify=#[verify]#</link>
|
||||||
<image>
|
<image>
|
||||||
<url>#[rssYacyImageURL]#</url>
|
<url>#[rssYacyImageURL]#</url>
|
||||||
<title>Search for #[rss_query]#</title>
|
<title>Search for #[rss_query]#</title>
|
||||||
<link>#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[input_resource]#&contentdom=#[input_contentdom]#&verify=#[input_verify]#</link>
|
<link>#[searchBaseURL]#?query=#[rss_queryenc]#&resource=#[resource]#&contentdom=#[contentdom]#&verify=#[verify]#</link>
|
||||||
</image>
|
</image>
|
||||||
<opensearch:totalResults>#[num-results_totalcount]#</opensearch:totalResults>
|
<opensearch:totalResults>#[num-results_totalcount]#</opensearch:totalResults>
|
||||||
<opensearch:startIndex>#[num-results_offset]#</opensearch:startIndex>
|
<opensearch:startIndex>#[num-results_offset]#</opensearch:startIndex>
|
||||||
|
|
|
@ -243,8 +243,12 @@ public final class plasmaSearchQuery {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static TreeSet<String>[] cleanQuery(String querystring) {
|
public static TreeSet<String>[] cleanQuery(String querystring) {
|
||||||
// returns three sets: a query set, a exclude set and a full query set
|
// returns three sets: a query set, a exclude set and a full query set
|
||||||
if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{new TreeSet<String>(NaturalOrder.naturalComparator), new TreeSet<String>(NaturalOrder.naturalComparator)};
|
final TreeSet<String> query = new TreeSet<String>(NaturalOrder.naturalComparator);
|
||||||
|
final TreeSet<String> exclude = new TreeSet<String>(NaturalOrder.naturalComparator);
|
||||||
|
final TreeSet<String> fullquery = new TreeSet<String>(NaturalOrder.naturalComparator);
|
||||||
|
|
||||||
|
if ((querystring == null) || (querystring.length() == 0)) return new TreeSet[]{query, exclude, fullquery};
|
||||||
|
|
||||||
// convert Umlaute
|
// convert Umlaute
|
||||||
querystring = htmlFilterAbstractScraper.stripAll(querystring).toLowerCase().trim();
|
querystring = htmlFilterAbstractScraper.stripAll(querystring).toLowerCase().trim();
|
||||||
|
@ -256,9 +260,6 @@ public final class plasmaSearchQuery {
|
||||||
String s;
|
String s;
|
||||||
int l;
|
int l;
|
||||||
// the string is clean now, but we must generate a set out of it
|
// the string is clean now, but we must generate a set out of it
|
||||||
final TreeSet<String> query = new TreeSet<String>(NaturalOrder.naturalComparator);
|
|
||||||
final TreeSet<String> exclude = new TreeSet<String>(NaturalOrder.naturalComparator);
|
|
||||||
final TreeSet<String> fullquery = new TreeSet<String>(NaturalOrder.naturalComparator);
|
|
||||||
final String[] a = querystring.split(" ");
|
final String[] a = querystring.split(" ");
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (int i = 0; i < a.length; i++) {
|
||||||
if (a[i].startsWith("-")) {
|
if (a[i].startsWith("-")) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user