- re-implemented image search

- generalized search result status bar, is now also visible during text search


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4077 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 6c819a6fd9
commit 6c3bcadc1c

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<yacyUrlInfo>
<!-- Resource metadata -->
<meta>
<url>#(error)##[url]#::#(/error)#</url>
<hash>#(error)##[hash]#::#(/error)#</hash>
<wordCount>#(error)##[wordCount]#::#(/error)#</wordCount>
<desc>#(error)##[desc]#::#(/error)#</desc>
<size>#(error)##[size]#::#(/error)#</size>
<mimeType>#(error)##[mimeType]#::#(/error)#</mimeType>
<statusCode>#(error)#0::1::2::3::4::5::6#(/error)#</statusCode>
<statusText>
#(error)#OK
::No URL hash submitted
::Unable to find URL Entry in DB
::Invalid URL
::Unable to download resource content: #[errorText]#
::Unable to parse resource content: #[errorText]#
::Unsupported protocol
#(/error)#
</statusText>
</meta>
<!-- resource body -->
<body mode="#(viewMode)#::1::2::3#(/viewMode)#">
#(viewMode)#
:: <!-- 1 -->
<![CDATA[#[plainText]#]]>
:: <!-- 2 -->
<![CDATA[#[parsedText]#]]>
:: <!-- 3 -->
#{sentences}#
<sentence nr="#[nr]#"><![CDATA[#[text]#]]></sentence>
#{/sentences}#
#(/viewMode)#
</body>
</yacyUrlInfo>

@ -51,165 +51,6 @@ function Progressbar(length, parent) {
parent.appendChild(this.element); parent.appendChild(this.element);
} }
function handleTextState(req) {
if(req.readyState != 4){
return;
}
var response = req.responseXML;
var snippetText = response.getElementsByTagName("text")[0].firstChild.data;
var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var status = response.getElementsByTagName("status")[0].firstChild.data;
var span = document.getElementById("h" + urlHash);
removeAllChildren(span);
//span.removeChild(span.firstChild);
if (status < 11) {
span.className = "snippetLoaded";
} else {
span.className = "snippetError";
span.parentNode.parentNode.className = "searchresults hidden";
document.getElementById("hidden_results").innerHTML='Some results were hidden, because they do not contain your searchwords anymore, or because they are not accessible. Click here to <a href="javascript:show_hidden_results()">show them</a>';
}
// set URL to favicon (if a link-tag was found in the document)
if (response.getElementsByTagName("favicon")[0].firstChild != null) {
var img = document.getElementById("f" + urlHash);
img.src = "ViewImage.png?width=16&height=16&url=" + response.getElementsByTagName("favicon")[0].firstChild.data;
}
// replace "<b>" text by <strong> node
var pos1=snippetText.indexOf("<b>");
var pos2=snippetText.indexOf("</b>");
while (pos1 >= 0 && pos2 > pos1) {
leftString = document.createTextNode(snippetText.substring(0, pos1)); //other text
if (leftString != "") span.appendChild(leftString);
//add the bold text
strongNode=document.createElement("strong");
middleString=document.createTextNode(snippetText.substring(pos1 + 3, pos2));
strongNode.appendChild(middleString);
span.appendChild(strongNode);
// cut out left and middle and go on with remaining text
snippetText=snippetText.substring(pos2 + 4);
pos1=snippetText.indexOf("<b>");
pos2=snippetText.indexOf("</b>");
}
// add remaining string
if (snippetText != "") {
span.appendChild(document.createTextNode(snippetText));
}
}
function handleMediaState(req, progressbar) {
if(req.readyState != 4){
return;
}
var response = req.responseXML;
// On errors, the result might not contain what we look for...
if (response.getElementsByTagName("urlHash")) {
var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var links = response.getElementsByTagName("links")[0].firstChild.data;
var container = document.getElementById("results");
if (links > 0) {
for (i = 0; i < links; i++) {
var type = response.getElementsByTagName("type")[i].firstChild.data;
var href = response.getElementsByTagName("href")[i].firstChild.data;
var name = response.getElementsByTagName("name")[i].firstChild.data;
var attr = response.getElementsByTagName("attr")[i].firstChild.data;
var link = document.createElement("a");
link.setAttribute("href", href);
link.setAttribute("target", "_parent");
link.appendChild(document.createTextNode(name));
var title = document.createElement("h4");
title.className = "linktitle";
title.appendChild(link);
var urllink = document.createElement("a");
urllink.setAttribute("href", href);
urllink.setAttribute("target", "_parent");
urllink.appendChild(document.createTextNode(href));
var url = document.createElement("p");
url.className = "url";
url.appendChild(urllink);
var searchresultcontainer = document.createElement("div");
searchresultcontainer.className = "searchresults";
searchresultcontainer.appendChild(title);
searchresultcontainer.appendChild(url);
container.appendChild(searchresultcontainer);
document.getElementById("linkcount").innerHTML++;
}
}
}
progressbar.step(1);
}
function handleImageState(req, progressbar) {
if(req.readyState != 4)
return;
var response = req.responseXML;
// on errors, the result might not contain the expected elements and would throw an error, so we check for it here
if (response.getElementsByTagName("urlHash")) {
// the urlHash is not needed anymore at the moment
//var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var links = response.getElementsByTagName("links")[0].firstChild.data;
var div = document.getElementById("results")
if (links > 0) {
for (i = 0; i < links; i++) {
var type = response.getElementsByTagName("type")[i].firstChild.data;
var href = response.getElementsByTagName("href")[i].firstChild.data;
var code = response.getElementsByTagName("code")[i].firstChild.data;
var name = response.getElementsByTagName("name")[i].firstChild.data;
var attr = response.getElementsByTagName("attr")[i].firstChild.data;
var img = document.createElement("img");
img.setAttribute("src", "/ViewImage.png?maxwidth=96&maxheight=96&code=" + code);
img.setAttribute("alt", name);
var imganchor = document.createElement("a");
imganchor.setAttribute("href", href);
imganchor.className = "thumblink";
imganchor.appendChild(img);
var nameanchor = document.createElement("a");
nameanchor.setAttribute("href", href);
nameanchor.appendChild(document.createTextNode(name));
var textcontainer = document.createElement("div");
textcontainer.className = "TableCellDark";
textcontainer.appendChild(nameanchor);
var thumbcontainer = document.createElement("div");
thumbcontainer.className = "thumbcontainer";
thumbcontainer.appendChild(imganchor);
thumbcontainer.appendChild(textcontainer);
div.appendChild(thumbcontainer);
//span.appendChild(imganchor);
document.getElementById("linkcount").innerHTML++;
}
}
}
progressbar.step(1);
}
function addHover() { function addHover() {
if (document.all&&document.getElementById) { if (document.all&&document.getElementById) {
var divs = document.getElementsByTagName("div"); var divs = document.getElementsByTagName("div");

@ -103,100 +103,27 @@ document.getElementById("Enter").value = "search again - catch up more links";
:: ::
<p>No Results. &quot;<strong>#[wrong_regex]#</strong>&quot; is no valid regular expression. Please go back to the previous page and make sure to enter a valid regular expressions for URL mask and Prefer mask.</p> <p>No Results. &quot;<strong>#[wrong_regex]#</strong>&quot; is no valid regular expression. Please go back to the previous page and make sure to enter a valid regular expressions for URL mask and Prefer mask.</p>
:: ::
<p><strong id="offset">#[offset]#</strong>-<strong id="itemscount">#[linkcount]#</strong> results from a total number of <strong id="totalcount">#[totalcount]#</strong> known#(globalresults)#.::, <strong id="globalcount">#[globalcount]#</strong> links from other YaCy peers.#(/globalresults)#</p> <p><strong id="offset">#[offset]#</strong>-<strong id="itemscount">#[linkcount]#</strong> results from a total number of <strong id="totalcount">#[totalcount]#</strong> known#(globalresults)#.::, <strong id="globalcount">#[globalcount]#</strong> links from other YaCy peers.#(/globalresults)#<div id="results"></div></p>
<p>Search Result Pages: <span id="pagenav">#[pagenav]#</span></p> <p>Search Result Pages: <span id="pagenav">#[pagenav]#</span></p>
:: ::
<p>Searching the web with this peer is disabled for unauthorized users. Please <a href="Status.html?login=">log in</a> as administrator to use the search function</p> <p>Searching the web with this peer is disabled for unauthorized users. Please <a href="Status.html?login=">log in</a> as administrator to use the search function</p>
#(/num-results)# #(/num-results)#
<!-- view the result list --> <!-- the search results -->
#(type)# #(combine)#::
<!-- type 0: text search --> <p><strong>Refine with</strong>:</p>
#(combine)# <p>#{words}#<a href="yacysearch.html?search=#[newsearch]#&amp;Enter=Search&amp;count=#[count]#&amp;offset=#[offset]#&amp;resource=#[resource]#&amp;time=#[time]#">#[word]#</a>#{/words}#</p>
:: #(/combine)#
<p><strong>Refine with</strong>:</p> <script type="text/javascript">
<p> var progressbar = new Progressbar(#[results]#, document.getElementById("results"));
#{words}# </script>
<a href="yacysearch.html?search=#[newsearch]#&amp;Enter=Search&amp;count=#[count]#&amp;offset=#[offset]#&amp;resource=#[resource]#&amp;time=#[time]#">#[word]#</a>
#{/words}#
</p>
#(/combine)#
<!-- linklist begin -->
<div id="hidden_results"></div>
#{results}#
<!--#include virtual="yacysearchitem.html?item=#[item]#&eventID=#[eventID]#&display=#[display]#" -->
#{/results}#
<!-- linklist end -->
::<!-- type 1: media search -->
<!-- non-js variant -->
<noscript>
<p>
Sorry, at the moment you need JavaScript in order to use this search. But here are the urls where YaCy would have looked for your searchresults. Perhaps you can find them there. Sorry for the inconvenience. If you want a non-JavaScript search, beg the developers for it.
</p>
<!-- linklist begin -->
<ul>
#{results}#
<!-- link begin -->
<li><a href="#[url]#">#[urlname]#</a></li>
<!-- link end -->
#{/results}#
</ul>
<!-- linklist end -->
</noscript>
<!-- linklist start-->
<div id="results">
</div>
<!-- linklist end-->
<script type="text/javascript">
var urls = "#{results}##[urlname]# #{/results}#".split(" ");
// the last element is always empty because the split gets a space at the end of the string
urls.length--;
if(urls.length > 0) {
AllMediaSnippets(urls, "#[former]#", "#[mediatype]#");
}
</script>
::<!-- type 2: image search: presents image thumbnails -->
<noscript>
<p>
Sorry, but in order to use the image search, you need JavaScript. But here are the urls where YaCy would have looked for the images you want. Perhaps you can find them there. Sorry for the inconvenience. If you want a non-JavaScript image search, beg the developers for it.
</p>
<ul>
#{results}#
<li><a href="#[url]#">#[urlname]#</a></li>
#{/results}#
</ul>
</noscript>
<!-- linklist start -->
<div id="results">
</div>
<!-- linklist end -->
<script type="text/javascript">
var urls = "#{results}##[urlname]# #{/results}#".split(" ");
// the last element is always empty because the split gets a space at the end of the string
urls.length--;
if(urls.length > 0) {
AllImageSnippets(urls, "#[former]#");
}
</script>
<br style="clear:left;" />
::<!-- type 3: image thumbnail list for one single url -->
<table border="0" cellspacing="16" cellpadding="0">
#{results}#
<tr valign="bottom">
#{line}#
<td>
<a href="#[url]#"><img src="/ViewImage.png?maxwidth=96&amp;maxheight=96&amp;url=#[url]#" /></a><br /><a href="#[url]#">#[name]#</a>
</td>
#{/line}#
</tr>
#{/results}#
</table>
#(/type)# <!-- linklist begin -->
<div id="hidden_results"></div>
#{results}#
<!--#include virtual="yacysearchitem.html?item=#[item]#&eventID=#[eventID]#" -->
#{/results}#
<!-- linklist end -->
</body> </body>
</html> </html>

@ -52,7 +52,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeSet; import java.util.TreeSet;
import de.anomic.htmlFilter.htmlFilterImageEntry;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.index.indexURLEntry; import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroBitfield; import de.anomic.kelondro.kelondroBitfield;
@ -61,7 +60,6 @@ import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.plasma.plasmaCondenser; import de.anomic.plasma.plasmaCondenser;
import de.anomic.plasma.plasmaParserDocument; import de.anomic.plasma.plasmaParserDocument;
import de.anomic.plasma.plasmaSearchEvent; import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchImages;
import de.anomic.plasma.plasmaSearchQuery; import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProfile; import de.anomic.plasma.plasmaSearchRankingProfile;
import de.anomic.plasma.plasmaSearchProcessing; import de.anomic.plasma.plasmaSearchProcessing;
@ -141,10 +139,9 @@ public class yacysearch {
prop.put("input_contentdomCheckVideo", 0); prop.put("input_contentdomCheckVideo", 0);
prop.put("input_contentdomCheckImage", 0); prop.put("input_contentdomCheckImage", 0);
prop.put("input_contentdomCheckApp", 0); prop.put("input_contentdomCheckApp", 0);
prop.put("type", 0); prop.put("excluded", 0);
prop.put("type_excluded", 0); prop.put("combine", 0);
prop.put("type_combine", 0); prop.put("results", "");
prop.put("type_results", "");
prop.put("num-results", (searchAllowed) ? 0 : 6); prop.put("num-results", (searchAllowed) ? 0 : 6);
return prop; return prop;
@ -193,70 +190,70 @@ public class yacysearch {
int contentdomCode = plasmaSearchQuery.contentdomParser(post.get("contentdom", "text")); int contentdomCode = plasmaSearchQuery.contentdomParser(post.get("contentdom", "text"));
// patch until better search profiles are available // patch until better search profiles are available
if ((contentdomCode != plasmaSearchQuery.CONTENTDOM_TEXT) && (count <= 10)) count = 30; if ((contentdomCode != plasmaSearchQuery.CONTENTDOM_TEXT) && (count <= 30)) count = 30;
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
if (post.get("cat", "href").equals("href")) { if (post.get("cat", "href").equals("href")) {
final TreeSet[] query = plasmaSearchQuery.cleanQuery(querystring); // converts also umlaute final TreeSet[] query = plasmaSearchQuery.cleanQuery(querystring); // converts also umlaute
// filter out stopwords // filter out stopwords
final TreeSet filtered = kelondroMSetTools.joinConstructive(query[0], plasmaSwitchboard.stopwords); final TreeSet filtered = kelondroMSetTools.joinConstructive(query[0], plasmaSwitchboard.stopwords);
if (filtered.size() > 0) { if (filtered.size() > 0) {
kelondroMSetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords); kelondroMSetTools.excludeDestructive(query[0], plasmaSwitchboard.stopwords);
}
// if a minus-button was hit, remove a special reference first
if (post.containsKey("deleteref")) {
if (!sb.verifyAuthentication(header, true)) {
prop.put("AUTHENTICATE", "admin log-in"); // force log-in
return prop;
} }
// delete the index entry locally // if a minus-button was hit, remove a special reference first
final String delHash = post.get("deleteref", ""); // urlhash if (post.containsKey("deleteref")) {
sb.wordIndex.removeWordReferences(query[0], delHash); if (!sb.verifyAuthentication(header, true)) {
prop.put("AUTHENTICATE", "admin log-in"); // force log-in
return prop;
}
// make new news message with negative voting // delete the index entry locally
HashMap map = new HashMap(); final String delHash = post.get("deleteref", ""); // urlhash
map.put("urlhash", delHash); sb.wordIndex.removeWordReferences(query[0], delHash);
map.put("vote", "negative");
map.put("refid", "");
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));
}
// if a plus-button was hit, create new voting message // make new news message with negative voting
if (post.containsKey("recommendref")) { HashMap map = new HashMap();
if (!sb.verifyAuthentication(header, true)) { map.put("urlhash", delHash);
prop.put("AUTHENTICATE", "admin log-in"); // force log-in map.put("vote", "negative");
return prop; map.put("refid", "");
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));
} }
final String recommendHash = post.get("recommendref", ""); // urlhash
indexURLEntry urlentry = sb.wordIndex.loadedURL.load(recommendHash, null); // if a plus-button was hit, create new voting message
if (urlentry != null) { if (post.containsKey("recommendref")) {
indexURLEntry.Components comp = urlentry.comp(); if (!sb.verifyAuthentication(header, true)) {
plasmaParserDocument document; prop.put("AUTHENTICATE", "admin log-in"); // force log-in
document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true); return prop;
if (document != null) { }
// create a news message final String recommendHash = post.get("recommendref", ""); // urlhash
HashMap map = new HashMap(); indexURLEntry urlentry = sb.wordIndex.loadedURL.load(recommendHash, null);
map.put("url", comp.url().toNormalform(false, true).replace(',', '|')); if (urlentry != null) {
map.put("title", comp.title().replace(',', ' ')); indexURLEntry.Components comp = urlentry.comp();
map.put("description", ((document == null) ? comp.title() : document.getTitle()).replace(',', ' ')); plasmaParserDocument document;
map.put("author", ((document == null) ? "" : document.getAuthor())); document = plasmaSnippetCache.retrieveDocument(comp.url(), true, 5000, true);
map.put("tags", ((document == null) ? "" : document.getKeywords(' '))); if (document != null) {
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_ADD, map)); // create a news message
document.close(); HashMap map = new HashMap();
map.put("url", comp.url().toNormalform(false, true).replace(',', '|'));
map.put("title", comp.title().replace(',', ' '));
map.put("description", ((document == null) ? comp.title() : document.getTitle()).replace(',', ' '));
map.put("author", ((document == null) ? "" : document.getAuthor()));
map.put("tags", ((document == null) ? "" : document.getKeywords(' ')));
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_SURFTIPP_ADD, map));
document.close();
}
} }
} }
}
// prepare search properties // prepare search properties
final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed != null) && (yacyCore.seedDB.mySeed.getPublicAddress() != null)); final boolean yacyonline = ((yacyCore.seedDB != null) && (yacyCore.seedDB.mySeed != null) && (yacyCore.seedDB.mySeed.getPublicAddress() != null));
final boolean globalsearch = (global) && (yacyonline); final boolean globalsearch = (global) && (yacyonline);
// do the search // do the search
TreeSet queryHashes = plasmaCondenser.words2hashes(query[0]); TreeSet queryHashes = plasmaCondenser.words2hashes(query[0]);
plasmaSearchQuery theQuery = new plasmaSearchQuery( plasmaSearchQuery theQuery = new plasmaSearchQuery(
querystring, querystring,
queryHashes, queryHashes,
plasmaCondenser.words2hashes(query[1]), plasmaCondenser.words2hashes(query[1]),
@ -273,95 +270,94 @@ public class yacysearch {
"", "",
20, 20,
constraint); constraint);
plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile(contentdomCode) : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null)); plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile(contentdomCode) : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null));
plasmaSearchProcessing localTiming = new plasmaSearchProcessing(4 * theQuery.maximumTime / 10, theQuery.displayResults()); plasmaSearchProcessing localTiming = new plasmaSearchProcessing(4 * theQuery.maximumTime / 10, theQuery.displayResults());
String client = (String) header.get("CLIENTIP"); // the search client who initiated the search String client = (String) header.get("CLIENTIP"); // the search client who initiated the search
// tell all threads to do nothing for a specific time // tell all threads to do nothing for a specific time
sb.intermissionAllThreads(2 * theQuery.maximumTime); sb.intermissionAllThreads(2 * theQuery.maximumTime);
// filter out words that appear in bluelist // filter out words that appear in bluelist
theQuery.filterOut(plasmaSwitchboard.blueList); theQuery.filterOut(plasmaSwitchboard.blueList);
// log // log
serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed, " + (theQuery.maximumTime / 1000) + " seconds"); serverLog.logInfo("LOCAL_SEARCH", "INIT WORD SEARCH: " + theQuery.queryString + ":" + theQuery.queryHashes + " - " + theQuery.neededResults() + " links to be computed, " + theQuery.displayResults() + " lines to be displayed, " + (theQuery.maximumTime / 1000) + " seconds");
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
// create a new search event // create a new search event
String wrongregex = null; String wrongregex = null;
if (plasmaSearchEvent.getEvent(theQuery.id()) == null) { if (plasmaSearchEvent.getEvent(theQuery.id()) == null) {
theQuery.setOffset(0); // in case that this is a new search, always start without a offset theQuery.setOffset(0); // in case that this is a new search, always start without a offset
offset = 0; offset = 0;
} }
plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(theQuery, ranking, localTiming, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null, false, null); plasmaSearchEvent theSearch = plasmaSearchEvent.getEvent(theQuery, ranking, localTiming, sb.wordIndex, (sb.isRobinsonMode()) ? sb.clusterhashes : null, false, null);
// generate result object // generate result object
serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER ORDERING OF SEARCH RESULTS: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");
serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");
// calc some more cross-reference // calc some more cross-reference
long remainingTime = theQuery.maximumTime - (System.currentTimeMillis() - timestamp); long remainingTime = theQuery.maximumTime - (System.currentTimeMillis() - timestamp);
if (remainingTime < 0) remainingTime = 1000; if (remainingTime < 0) remainingTime = 1000;
serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); serverLog.logFine("LOCAL_SEARCH", "SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");
// log // log
serverLog.logInfo("LOCAL_SEARCH", "EXIT WORD SEARCH: " + theQuery.queryString + " - " + serverLog.logInfo("LOCAL_SEARCH", "EXIT WORD SEARCH: " + theQuery.queryString + " - " +
(theSearch.getLocalCount() + theSearch.getGlobalCount()) + " links found, " + (theSearch.getLocalCount() + theSearch.getGlobalCount()) + " links found, " +
((System.currentTimeMillis() - timestamp) / 1000) + " seconds"); ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");
// prepare search statistics // prepare search statistics
Long trackerHandle = new Long(System.currentTimeMillis()); Long trackerHandle = new Long(System.currentTimeMillis());
HashMap searchProfile = theQuery.resultProfile(theSearch.getLocalCount() + theSearch.getGlobalCount(), System.currentTimeMillis() - timestamp); HashMap searchProfile = theQuery.resultProfile(theSearch.getLocalCount() + theSearch.getGlobalCount(), System.currentTimeMillis() - timestamp);
searchProfile.put("querystring", theQuery.queryString); searchProfile.put("querystring", theQuery.queryString);
searchProfile.put("time", trackerHandle); searchProfile.put("time", trackerHandle);
searchProfile.put("host", client); searchProfile.put("host", client);
searchProfile.put("offset", new Integer(0)); searchProfile.put("offset", new Integer(0));
sb.localSearches.add(searchProfile); sb.localSearches.add(searchProfile);
TreeSet handles = (TreeSet) sb.localSearchTracker.get(client); TreeSet handles = (TreeSet) sb.localSearchTracker.get(client);
if (handles == null) handles = new TreeSet(); if (handles == null) handles = new TreeSet();
handles.add(trackerHandle); handles.add(trackerHandle);
sb.localSearchTracker.put(client, handles); sb.localSearchTracker.put(client, handles);
prop = new serverObjects(); prop = new serverObjects();
prop.put("num-results_totalcount", theSearch.getLocalCount() + theSearch.getGlobalCount()); prop.put("num-results_totalcount", theSearch.getLocalCount() + theSearch.getGlobalCount());
prop.put("num-results_globalresults", 1); prop.put("num-results_globalresults", 1);
prop.put("num-results_globalresults_globalcount", theSearch.getGlobalCount()); prop.put("num-results_globalresults_globalcount", theSearch.getGlobalCount());
prop.put("num-results_offset", 0); prop.put("num-results_offset", 0);
prop.put("num-results_linkcount", 0); prop.put("num-results_linkcount", 0);
// compose page navigation // compose page navigation
StringBuffer pagenav = new StringBuffer(); StringBuffer pagenav = new StringBuffer();
int thispage = offset / theQuery.displayResults(); int thispage = offset / theQuery.displayResults();
if (thispage == 0) pagenav.append("&lt;&nbsp;"); else { if (thispage == 0) pagenav.append("&lt;&nbsp;"); else {
pagenav.append(navurla(thispage - 1, display, theQuery)); pagenav.append(navurla(thispage - 1, display, theQuery));
pagenav.append("<strong>&lt;</strong></a>&nbsp;"); pagenav.append("<strong>&lt;</strong></a>&nbsp;");
}
int numberofpages = Math.min(10, Math.min(thispage + 2, (theSearch.getGlobalCount() + theSearch.getLocalCount()) / theQuery.displayResults()));
for (int i = 0; i < numberofpages; i++) {
if (i == thispage) {
pagenav.append("<strong>");
pagenav.append(i + 1);
pagenav.append("</strong>&nbsp;");
} else {
pagenav.append(navurla(i, display, theQuery));
pagenav.append(i + 1);
pagenav.append("</a>&nbsp;");
} }
} int numberofpages = Math.min(10, Math.min(thispage + 2, (theSearch.getGlobalCount() + theSearch.getLocalCount()) / theQuery.displayResults()));
if (thispage >= numberofpages) pagenav.append("&gt;"); else { for (int i = 0; i < numberofpages; i++) {
pagenav.append(navurla(thispage + 1, display, theQuery)); if (i == thispage) {
pagenav.append("<strong>&gt;</strong></a>"); pagenav.append("<strong>");
} pagenav.append(i + 1);
prop.putASIS("num-results_pagenav", pagenav.toString()); pagenav.append("</strong>&nbsp;");
} else {
pagenav.append(navurla(i, display, theQuery));
pagenav.append(i + 1);
pagenav.append("</a>&nbsp;");
}
}
if (thispage >= numberofpages) pagenav.append("&gt;"); else {
pagenav.append(navurla(thispage + 1, display, theQuery));
pagenav.append("<strong>&gt;</strong></a>");
}
prop.putASIS("num-results_pagenav", pagenav.toString());
// generate the search result lines; they will be produced by another servlet // generate the search result lines; they will be produced by another servlet
for (int i = 0; i < theQuery.displayResults(); i++) { for (int i = 0; i < theQuery.displayResults(); i++) {
prop.put("type_results_" + i + "_item", offset + i); prop.put("results_" + i + "_item", offset + i);
prop.put("type_results_" + i + "_eventID", theQuery.id()); prop.put("results_" + i + "_eventID", theQuery.id());
prop.put("type_results_" + i + "_display", display); }
} prop.put("results", theQuery.displayResults());
prop.put("type_results", theQuery.displayResults());
// process result of search // process result of search
if (filtered.size() > 0) { if (filtered.size() > 0) {
@ -384,7 +380,7 @@ public class yacysearch {
prop.put("num-results", 5); prop.put("num-results", 5);
int hintcount = references.length; int hintcount = references.length;
if (hintcount > 0) { if (hintcount > 0) {
prop.put("type_combine", 1); prop.put("combine", 1);
// get the topwords // get the topwords
final TreeSet topwords = new TreeSet(kelondroNaturalOrder.naturalOrder); final TreeSet topwords = new TreeSet(kelondroNaturalOrder.naturalOrder);
String tmp = ""; String tmp = "";
@ -414,14 +410,14 @@ public class yacysearch {
while (iter.hasNext()) { while (iter.hasNext()) {
word = (String) iter.next(); word = (String) iter.next();
if (word != null) { if (word != null) {
prop.put("type_combine_words_" + hintcount + "_word", word); prop.put("combine_words_" + hintcount + "_word", word);
prop.put("type_combine_words_" + hintcount + "_newsearch", post.get("search", "").replace(' ', '+') + "+" + word); prop.put("combine_words_" + hintcount + "_newsearch", post.get("search", "").replace(' ', '+') + "+" + word);
prop.put("type_combine_words_" + hintcount + "_count", count); prop.put("combine_words_" + hintcount + "_count", count);
prop.put("type_combine_words_" + hintcount + "_offset", offset); prop.put("combine_words_" + hintcount + "_offset", offset);
prop.put("type_combine_words_" + hintcount + "_resource", ((global) ? "global" : "local")); prop.put("combine_words_" + hintcount + "_resource", ((global) ? "global" : "local"));
prop.put("type_combine_words_" + hintcount + "_time", (searchtime / 1000)); prop.put("combine_words_" + hintcount + "_time", (searchtime / 1000));
} }
prop.put("type_combine_words", hintcount); prop.put("combine_words", hintcount);
if (hintcount++ > MAX_TOPWORDS) { if (hintcount++ > MAX_TOPWORDS) {
break; break;
} }
@ -437,11 +433,8 @@ public class yacysearch {
} }
} }
prop.put("type", (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_TEXT) ? 0 : ((theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_IMAGE) ? 2 : 1));
if (prop.getInt("type", 0) == 1) prop.put("type_mediatype", post.get("contentdom", "text"));
prop.put("input_cat", "href"); prop.put("input_cat", "href");
prop.put("input_depth", "0"); prop.put("input_depth", "0");
prop.put("type_eventID", theQuery.id());
// 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");
@ -449,44 +442,6 @@ public class yacysearch {
prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif"); prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif");
} }
if (post.get("cat", "href").equals("image")) {
int depth = post.getInt("depth", 0);
int columns = post.getInt("columns", 6);
yacyURL url = null;
try {url = new yacyURL(post.get("url", ""), null);} catch (MalformedURLException e) {}
plasmaSearchImages si = new plasmaSearchImages(6000, url, depth);
Iterator i = si.entries();
htmlFilterImageEntry ie;
int line = 0;
while (i.hasNext()) {
int col = 0;
for (col = 0; col < columns; col++) {
if (!i.hasNext()) break;
ie = (htmlFilterImageEntry) i.next();
String urls = ie.url().toString();
String name = "";
int p = urls.lastIndexOf('/');
if (p > 0) name = urls.substring(p + 1);
prop.put("type_results_" + line + "_line_" + col + "_url", urls);
prop.put("type_results_" + line + "_line_" + col + "_name", name);
}
prop.put("type_results_" + line + "_line", col);
line++;
}
prop.put("type_results", line);
prop.put("type", 3); // set type of result: image list
prop.put("input_cat", "href");
prop.put("input_depth", depth);
}
// if user is not authenticated, he may not vote for URLs
int linkcount = Integer.parseInt(prop.get("num-results_linkcount", "0"));
for (int i=0; i<linkcount; i++) {
prop.put("type_results_" + i + "_authorized", (authenticated) ? 1 : 0);
}
prop.put("searchagain", (global) ? 1 : 0); prop.put("searchagain", (global) ? 1 : 0);
prop.put("input", input); prop.put("input", input);
prop.put("display", display); prop.put("display", display);
@ -509,7 +464,6 @@ public class yacysearch {
prop.put("input_contentdomCheckVideo", (contentdomCode == plasmaSearchQuery.CONTENTDOM_VIDEO) ? 1 : 0); prop.put("input_contentdomCheckVideo", (contentdomCode == plasmaSearchQuery.CONTENTDOM_VIDEO) ? 1 : 0);
prop.put("input_contentdomCheckImage", (contentdomCode == plasmaSearchQuery.CONTENTDOM_IMAGE) ? 1 : 0); prop.put("input_contentdomCheckImage", (contentdomCode == plasmaSearchQuery.CONTENTDOM_IMAGE) ? 1 : 0);
prop.put("input_contentdomCheckApp", (contentdomCode == plasmaSearchQuery.CONTENTDOM_APP) ? 1 : 0); prop.put("input_contentdomCheckApp", (contentdomCode == plasmaSearchQuery.CONTENTDOM_APP) ? 1 : 0);
prop.put("type_former", post.get("search", "")); //the query-string used to get the snippets
// return rewrite properties // return rewrite properties
return prop; return prop;

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<yacySearch>
<yacySearchResult>
<title>Search for #[former]#</title>
<description>Search for #[former]#</description>
#(type)#
<totalResultCount>#(num-results)#::::::::#[totalcount]##(/num-results)#</totalResultCount>
<currentResultCount>#(num-results)#::::::::#[linkcount]##(/num-results)#</currentResultCount>
<!-- StopWords -->
<stopWords>#(excluded)#::#[stopwords]##(/excluded)#</stopWords>
<!-- YaCy Top-Worts -->
<topWords>
#(combine)#::
#{words}#<word query="#[newsearch]#">#[word]#</word>#{/words}#
#(/combine)#
</topWords>
<!-- Search Results -->
#{results}#
<yacySearchResultItem>
<description>#[description]#</description>
<link>#[url]#</link>
<hash>#[urlhash]#</hash>
<linkName>#[urlname]#</linkName>
<pubDate>#[date]#</pubDate>
<size>#[size]#</size>
<ranking>YBR-#[ybr]#</ranking>
<snippet>#(snippet)#::<![CDATA[#[text]#]]>#(/snippet)#</snippet>
</yacySearchResultItem>
#{/results}#
::
#(/type)#
</yacySearchResult>
</yacySearch>

@ -15,12 +15,19 @@
#(/recommend)# #(/recommend)#
</div> </div>
#(/authorized)# #(/authorized)#
<p class="snippet"><span class="snippetLoaded" id="h#[urlhash]#">#[snippet]#</span></p> <p class="snippet"><span class="snippetLoaded" id="h#[urlhash]#">#[snippet]#</span></p>
<p class="url"><a href="#[url]#" id="url#[urlhash]#" target="_parent">#[urlname]#</a></p> <p class="url"><a href="#[url]#" id="url#[urlhash]#" target="_parent">#[urlname]#</a></p>
<p class="urlinfo">#[date]# | YBR-#[ybr]# | <a href="ViewFile.html?urlHash=#[urlhash]#&amp;words=#[words]#">Info</a> | <a href="yacysearch.html?cat=image&amp;url=#[url]#&amp;search=#[former]#">Pictures</a></p> <p class="urlinfo">#[date]# | YBR-#[ybr]# | <a href="ViewFile.html?urlHash=#[urlhash]#&amp;words=#[words]#">Info</a> | <a href="yacysearch.html?cat=image&amp;url=#[url]#&amp;search=#[former]#">Pictures</a></p>
</div> </div>
::
#{images}#
<div class="thumbcontainer">
<a href="#[href]#" class="thumblink"><img src="/ViewImage.png?maxwidth=96&maxheight=96&code=#[code]#" alt="#[name]#"></a>
<div class="TableCellDark"><a href="#[href]#">#[name]#</a></div>
</div>
#{/images}#
#(/content)# #(/content)#
<script type="text/javascript"> <script type="text/javascript">
statistics("#[offset]#", "#[items]#", "#[global]#", "#[total]#"); statistics("#[offset]#", "#[items]#", "#[global]#", "#[total]#");
progressbar.step(1);
</script> </script>

@ -27,6 +27,7 @@
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.TreeSet; import java.util.TreeSet;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
@ -34,6 +35,7 @@ import de.anomic.plasma.plasmaSearchEvent;
import de.anomic.plasma.plasmaSearchPreOrder; import de.anomic.plasma.plasmaSearchPreOrder;
import de.anomic.plasma.plasmaSearchQuery; import de.anomic.plasma.plasmaSearchQuery;
import de.anomic.plasma.plasmaSearchRankingProfile; import de.anomic.plasma.plasmaSearchRankingProfile;
import de.anomic.plasma.plasmaSnippetCache;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
@ -53,7 +55,6 @@ public class yacysearchitem {
String eventID = post.get("eventID", ""); String eventID = post.get("eventID", "");
int item = post.getInt("item", -1); int item = post.getInt("item", -1);
//int display = post.getInt("display", 0);
boolean authenticated = sb.adminAuthenticated(header) >= 2; boolean authenticated = sb.adminAuthenticated(header) >= 2;
// find search event // find search event
@ -75,42 +76,69 @@ public class yacysearchitem {
return prop; return prop;
} }
prop.put("content", 1); // switch on content prop.put("content", theQuery.contentdom + 1); // switch on specific content
prop.put("content_authorized", (authenticated) ? 1 : 0);
prop.put("content_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? 1 : 0); if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_TEXT) {
prop.put("content_authorized_recommend_deletelink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + result.hash() + "&urlmaskfilter=.*"); // text search
prop.put("content_authorized_recommend_recommendlink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + result.hash() + "&urlmaskfilter=.*"); prop.put("content_authorized", (authenticated) ? 1 : 0);
prop.put("content_authorized_urlhash", result.hash()); prop.put("content_authorized_recommend", (yacyCore.newsPool.getSpecific(yacyNewsPool.OUTGOING_DB, yacyNewsPool.CATEGORY_SURFTIPP_ADD, "url", result.urlstring()) == null) ? 1 : 0);
prop.put("content_description", result.title()); prop.put("content_authorized_recommend_deletelink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&deleteref=" + result.hash() + "&urlmaskfilter=.*");
prop.put("content_url", result.urlstring()); prop.put("content_authorized_recommend_recommendlink", "/yacysearch.html?search=" + theQuery.queryString + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(ranking.toExternalString()) + "&resource=local&time=3&recommendref=" + result.hash() + "&urlmaskfilter=.*");
prop.put("content_authorized_urlhash", result.hash());
int port=result.url().getPort(); prop.put("content_description", result.title());
yacyURL faviconURL; prop.put("content_url", result.urlstring());
try {
faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null); int port=result.url().getPort();
} catch (MalformedURLException e1) { yacyURL faviconURL;
faviconURL = null; try {
} faviconURL = new yacyURL(result.url().getProtocol() + "://" + result.url().getHost() + ((port != -1) ? (":" + String.valueOf(port)) : "") + "/favicon.ico", null);
} catch (MalformedURLException e1) {
prop.put("content_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // aquire license for favicon url loading faviconURL = null;
prop.put("content_urlhash", result.hash()); }
prop.put("content_urlhexhash", yacySeed.b64Hash2hexHash(result.hash()));
prop.put("content_urlname", nxTools.shortenURLString(result.urlname(), 120)); prop.put("content_faviconCode", sb.licensedURLs.aquireLicense(faviconURL)); // aquire license for favicon url loading
prop.put("content_date", plasmaSwitchboard.dateString(result.modified())); prop.put("content_urlhash", result.hash());
prop.put("content_ybr", plasmaSearchPreOrder.ybr(result.hash())); prop.put("content_urlhexhash", yacySeed.b64Hash2hexHash(result.hash()));
prop.put("content_size", Long.toString(result.filesize())); prop.put("content_urlname", nxTools.shortenURLString(result.urlname(), 120));
prop.put("content_date", plasmaSwitchboard.dateString(result.modified()));
TreeSet[] query = theQuery.queryWords(); prop.put("content_ybr", plasmaSearchPreOrder.ybr(result.hash()));
yacyURL wordURL = null; prop.put("content_size", Long.toString(result.filesize()));
try {
prop.put("content_words", URLEncoder.encode(query[0].toString(),"UTF-8")); TreeSet[] query = theQuery.queryWords();
} catch (UnsupportedEncodingException e) {} yacyURL wordURL = null;
prop.put("content_former", theQuery.queryString); try {
prop.put("content_rankingprops", result.word().toPropertyForm() + ", domLengthEstimated=" + yacyURL.domLengthEstimation(result.hash()) + prop.put("content_words", URLEncoder.encode(query[0].toString(),"UTF-8"));
} catch (UnsupportedEncodingException e) {}
prop.put("content_former", theQuery.queryString);
prop.put("content_rankingprops", result.word().toPropertyForm() + ", domLengthEstimated=" + yacyURL.domLengthEstimation(result.hash()) +
((yacyURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") + ((yacyURL.probablyRootURL(result.hash())) ? ", probablyRootURL" : "") +
(((wordURL = yacyURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : "")); (((wordURL = yacyURL.probablyWordURL(result.hash(), query[0])) != null) ? ", probablyWordURL=" + wordURL.toNormalform(false, true) : ""));
prop.putASIS("content_snippet", result.textSnippet().getLineMarked(theQuery.queryHashes)); prop.putASIS("content_snippet", result.textSnippet().getLineMarked(theQuery.queryHashes));
}
if (theQuery.contentdom == plasmaSearchQuery.CONTENTDOM_IMAGE) {
// image search; shows thumbnails
// iterate over all images in the result
ArrayList /* of plasmaSnippetCache.MediaSnippet */ images = result.mediaSnippets();
if (images != null) {
plasmaSnippetCache.MediaSnippet ms;
yacyURL url;
int c = 0;
for (int i = 0; i < images.size(); i++) {
ms = (plasmaSnippetCache.MediaSnippet) images.get(i);
try {url = new yacyURL(ms.href, null);} catch (MalformedURLException e) {continue;}
prop.put("content_images_" + i + "_href", ms.href);
prop.put("content_images_" + i + "_code", sb.licensedURLs.aquireLicense(url));
prop.put("content_images_" + i + "_name", ms.name);
prop.put("content_images_" + i + "_attr", ms.attr); // attributes, here: original size of image
c++;
}
prop.put("content_images", c);
} else {
prop.put("content_images", 0);
}
}
return prop; return prop;
} }

Loading…
Cancel
Save