- fixed image search page navigation

- removed some deadlocks and ConcurrentModificationExceptions during
DidYouMean collection
pull/1/head
Michael Peter Christen 13 years ago
parent 125d47b3c1
commit 7bf421b9dd

@ -257,7 +257,7 @@ public final class search {
header.get(RequestHeader.USER_AGENT, ""), header.get(RequestHeader.USER_AGENT, ""),
false false
); );
Network.log.logInfo("INIT HASH SEARCH (abstracts only): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links"); Network.log.logInfo("INIT HASH SEARCH (abstracts only): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.itemsPerPage() + " links");
final long timer = System.currentTimeMillis(); final long timer = System.currentTimeMillis();
//final Map<byte[], ReferenceContainer<WordReference>>[] containers = sb.indexSegment.index().searchTerm(theQuery.queryHashes, theQuery.excludeHashes, plasmaSearchQuery.hashes2StringSet(urls)); //final Map<byte[], ReferenceContainer<WordReference>>[] containers = sb.indexSegment.index().searchTerm(theQuery.queryHashes, theQuery.excludeHashes, plasmaSearchQuery.hashes2StringSet(urls));
@ -320,7 +320,7 @@ public final class search {
header.get(RequestHeader.USER_AGENT, ""), header.get(RequestHeader.USER_AGENT, ""),
false false
); );
Network.log.logInfo("INIT HASH SEARCH (query-" + abstracts + "): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.displayResults() + " links"); Network.log.logInfo("INIT HASH SEARCH (query-" + abstracts + "): " + QueryParams.anonymizedQueryHashes(theQuery.queryHashes) + " - " + theQuery.itemsPerPage() + " links");
EventChannel.channels(EventChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.queryHashes), "")); EventChannel.channels(EventChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.queryHashes), ""));
// make event // make event

@ -31,6 +31,7 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -212,7 +213,7 @@ public class yacysearch {
// collect search attributes // collect search attributes
int maximumRecords = int itemsPerPage =
Math.min( Math.min(
(authenticated) (authenticated)
? (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline()
@ -275,10 +276,10 @@ public class yacysearch {
ContentDomain.contentdomParser(post == null ? "all" : post.get("contentdom", "all")); ContentDomain.contentdomParser(post == null ? "all" : post.get("contentdom", "all"));
// patch until better search profiles are available // patch until better search profiles are available
if (contentdom == ContentDomain.IMAGE && (maximumRecords == 10 || maximumRecords == 100)) { if (contentdom == ContentDomain.IMAGE && (itemsPerPage == 10 || itemsPerPage == 100)) {
maximumRecords = 64; itemsPerPage = 64;
} else if ( maximumRecords > 50 && maximumRecords < 100 ) { } else if ( contentdom != ContentDomain.IMAGE && itemsPerPage > 50 && itemsPerPage < 100 ) {
maximumRecords = 10; itemsPerPage = 10;
} }
// check the search tracker // check the search tracker
@ -736,7 +737,7 @@ public class yacysearch {
metatags, metatags,
navigation, navigation,
snippetFetchStrategy, snippetFetchStrategy,
maximumRecords, itemsPerPage,
startRecord, startRecord,
urlmask, urlmask,
clustersearch && global ? QueryParams.Searchdom.CLUSTER : (global && indexReceiveGranted clustersearch && global ? QueryParams.Searchdom.CLUSTER : (global && indexReceiveGranted
@ -781,7 +782,7 @@ public class yacysearch {
+ " - " + " - "
+ theQuery.neededResults() + theQuery.neededResults()
+ " links to be computed, " + " links to be computed, "
+ theQuery.displayResults() + theQuery.itemsPerPage()
+ " lines to be displayed"); + " lines to be displayed");
EventChannel.channels(EventChannel.LOCALSEARCH).addMessage( EventChannel.channels(EventChannel.LOCALSEARCH).addMessage(
new RSSMessage("Local Search Request", theQuery.queryString, "")); new RSSMessage("Local Search Request", theQuery.queryString, ""));
@ -858,21 +859,25 @@ public class yacysearch {
final Iterator<StringBuilder> meanIt = didYouMean.getSuggestions(100, 5).iterator(); final Iterator<StringBuilder> meanIt = didYouMean.getSuggestions(100, 5).iterator();
int meanCount = 0; int meanCount = 0;
String suggestion; String suggestion;
while ( meanCount < meanMax && meanIt.hasNext() ) { try {
suggestion = meanIt.next().toString(); meanCollect: while ( meanCount < meanMax && meanIt.hasNext() ) {
prop.put("didYouMean_suggestions_" + meanCount + "_word", suggestion); try {
prop.put( suggestion = meanIt.next().toString();
"didYouMean_suggestions_" + meanCount + "_url", prop.put("didYouMean_suggestions_" + meanCount + "_word", suggestion);
QueryParams.navurl( prop.put(
"html", "didYouMean_suggestions_" + meanCount + "_url",
0, QueryParams.navurl(
theQuery, "html",
suggestion, 0,
originalUrlMask.toString(), theQuery,
theQuery.navigators).toString()); suggestion,
prop.put("didYouMean_suggestions_" + meanCount + "_sep", "|"); originalUrlMask.toString(),
meanCount++; theQuery.navigators).toString());
} prop.put("didYouMean_suggestions_" + meanCount + "_sep", "|");
meanCount++;
} catch (ConcurrentModificationException e) {break meanCollect;}
}
} catch (ConcurrentModificationException e) {}
prop.put("didYouMean_suggestions_" + (meanCount - 1) + "_sep", ""); prop.put("didYouMean_suggestions_" + (meanCount - 1) + "_sep", "");
prop.put("didYouMean", meanCount > 0 ? 1 : 0); prop.put("didYouMean", meanCount > 0 ? 1 : 0);
prop.put("didYouMean_suggestions", meanCount); prop.put("didYouMean_suggestions", meanCount);
@ -931,7 +936,7 @@ public class yacysearch {
+ indexcount + indexcount
% theSearch.getQuery().itemsPerPage : startRecord + theSearch.getQuery().itemsPerPage, % theSearch.getQuery().itemsPerPage : startRecord + theSearch.getQuery().itemsPerPage,
true)); true));
prop.put("num-results_itemsPerPage", maximumRecords); prop.put("num-results_itemsPerPage", itemsPerPage);
prop.put("num-results_totalcount", Formatter.number(indexcount, true)); prop.put("num-results_totalcount", Formatter.number(indexcount, true));
prop.put("num-results_globalresults", global && (indexReceiveGranted || clustersearch) prop.put("num-results_globalresults", global && (indexReceiveGranted || clustersearch)
? "1" ? "1"
@ -954,7 +959,7 @@ public class yacysearch {
// compose page navigation // compose page navigation
final StringBuilder resnav = new StringBuilder(200); final StringBuilder resnav = new StringBuilder(200);
final int thispage = startRecord / theQuery.displayResults(); final int thispage = startRecord / theQuery.itemsPerPage();
if ( thispage == 0 ) { if ( thispage == 0 ) {
resnav resnav
.append("<img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" />&nbsp;"); .append("<img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" />&nbsp;");
@ -970,7 +975,7 @@ public class yacysearch {
resnav resnav
.append("\"><img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" /></a>&nbsp;"); .append("\"><img src=\"env/grafics/navdl.gif\" alt=\"arrowleft\" width=\"16\" height=\"16\" /></a>&nbsp;");
} }
final int numberofpages = Math.min(10, 1 + ((indexcount - 1) / theQuery.displayResults())); final int numberofpages = Math.min(10, 1 + ((indexcount - 1) / theQuery.itemsPerPage()));
for ( int i = 0; i < numberofpages; i++ ) { for ( int i = 0; i < numberofpages; i++ ) {
if ( i == thispage ) { if ( i == thispage ) {
@ -1012,11 +1017,11 @@ public class yacysearch {
prop.put("pageNavBottom_resnav", resnavs); prop.put("pageNavBottom_resnav", resnavs);
// generate the search result lines; the content will be produced by another servlet // generate the search result lines; the content will be produced by another servlet
for ( int i = 0; i < theQuery.displayResults(); i++ ) { for ( int i = 0; i < theQuery.itemsPerPage(); i++ ) {
prop.put("results_" + i + "_item", startRecord + i); prop.put("results_" + i + "_item", startRecord + i);
prop.put("results_" + i + "_eventID", theQuery.id(false)); prop.put("results_" + i + "_eventID", theQuery.id(false));
} }
prop.put("results", theQuery.displayResults()); prop.put("results", theQuery.itemsPerPage());
prop prop
.put( .put(
"resultTable", "resultTable",
@ -1058,7 +1063,7 @@ public class yacysearch {
prop.put("searchagain", global ? "1" : "0"); prop.put("searchagain", global ? "1" : "0");
prop.putHTML("former", originalquerystring); prop.putHTML("former", originalquerystring);
prop.put("count", maximumRecords); prop.put("count", itemsPerPage);
prop.put("offset", startRecord); prop.put("offset", startRecord);
prop.put("resource", global ? "global" : "local"); prop.put("resource", global ? "global" : "local");
prop.putHTML("urlmaskfilter", originalUrlMask); prop.putHTML("urlmaskfilter", originalUrlMask);

@ -90,7 +90,7 @@ public class yacysearchitem {
// dynamically update count values // dynamically update count values
final int totalcount = theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount(); final int totalcount = theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount();
final int offset = theQuery.neededResults() - theQuery.displayResults() + 1; final int offset = theQuery.neededResults() - theQuery.itemsPerPage() + 1;
prop.put("offset", offset); prop.put("offset", offset);
prop.put("itemscount", Formatter.number(Math.min((item < 0) ? theQuery.neededResults() : item + 1, totalcount))); prop.put("itemscount", Formatter.number(Math.min((item < 0) ? theQuery.neededResults() : item + 1, totalcount)));
prop.put("itemsperpage", Formatter.number(theQuery.itemsPerPage)); prop.put("itemsperpage", Formatter.number(theQuery.itemsPerPage));
@ -131,10 +131,10 @@ public class yacysearchitem {
prop.put("content_authorized", authenticated ? "1" : "0"); prop.put("content_authorized", authenticated ? "1" : "0");
final String urlhash = ASCII.String(result.hash()); final String urlhash = ASCII.String(result.hash());
prop.put("content_authorized_bookmark", sb.tables.bookmarks.hasBookmark("admin", urlhash) ? "0" : "1"); prop.put("content_authorized_bookmark", sb.tables.bookmarks.hasBookmark("admin", urlhash) ? "0" : "1");
prop.putHTML("content_authorized_bookmark_bookmarklink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&bookmarkref=" + urlhash + "&urlmaskfilter=.*"); prop.putHTML("content_authorized_bookmark_bookmarklink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.itemsPerPage() + "&offset=" + (theQuery.neededResults() - theQuery.itemsPerPage()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&bookmarkref=" + urlhash + "&urlmaskfilter=.*");
prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0"); prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0");
prop.putHTML("content_authorized_recommend_deletelink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*"); prop.putHTML("content_authorized_recommend_deletelink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.itemsPerPage() + "&offset=" + (theQuery.neededResults() - theQuery.itemsPerPage()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
prop.putHTML("content_authorized_recommend_recommendlink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.displayResults() + "&offset=" + (theQuery.neededResults() - theQuery.displayResults()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&recommendref=" + urlhash + "&urlmaskfilter=.*"); prop.putHTML("content_authorized_recommend_recommendlink", "/yacysearch.html?query=" + theQuery.queryString.replace(' ', '+') + "&Enter=Search&count=" + theQuery.itemsPerPage() + "&offset=" + (theQuery.neededResults() - theQuery.itemsPerPage()) + "&order=" + crypt.simpleEncode(theQuery.ranking.toExternalString()) + "&resource=" + resource + "&time=3&recommendref=" + urlhash + "&urlmaskfilter=.*");
prop.put("content_authorized_urlhash", urlhash); prop.put("content_authorized_urlhash", urlhash);
final String resulthashString = urlhash; final String resulthashString = urlhash;
prop.putHTML("content_title", result.title()); prop.putHTML("content_title", result.title());

@ -34,7 +34,7 @@ public class yacysearchlatestinfo {
// dynamically update count values // dynamically update count values
final int totalcount = theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount(); final int totalcount = theSearch.getRankingResult().getLocalIndexCount() - theSearch.getRankingResult().getMissCount() - theSearch.getRankingResult().getSortOutCount() + theSearch.getRankingResult().getRemoteIndexCount();
final int offset = theQuery.neededResults() - theQuery.displayResults() + 1; final int offset = theQuery.neededResults() - theQuery.itemsPerPage() + 1;
prop.put("offset", offset); prop.put("offset", offset);
prop.put("itemscount",Formatter.number(offset + theSearch.getQuery().itemsPerPage >= totalcount ? offset + totalcount % theSearch.getQuery().itemsPerPage - 1 : offset + theSearch.getQuery().itemsPerPage - 1)); prop.put("itemscount",Formatter.number(offset + theSearch.getQuery().itemsPerPage >= totalcount ? offset + totalcount % theSearch.getQuery().itemsPerPage - 1 : offset + theSearch.getQuery().itemsPerPage - 1));
prop.put("itemsperpage", theSearch.getQuery().itemsPerPage); prop.put("itemsperpage", theSearch.getQuery().itemsPerPage);

@ -282,7 +282,7 @@ public final class QueryParams {
return this.offset + this.itemsPerPage; return this.offset + this.itemsPerPage;
} }
public int displayResults() { public int itemsPerPage() {
// the number of result lines that are displayed at once (size of result page) // the number of result lines that are displayed at once (size of result page)
return this.itemsPerPage; return this.itemsPerPage;
} }
@ -537,7 +537,7 @@ public final class QueryParams {
sb.append(ampersand); sb.append(ampersand);
sb.append("startRecord="); sb.append("startRecord=");
sb.append(page * theQuery.displayResults()); sb.append(page * theQuery.itemsPerPage());
return sb; return sb;
} }
@ -554,7 +554,7 @@ public final class QueryParams {
sb.append(ampersand); sb.append(ampersand);
sb.append("maximumRecords="); sb.append("maximumRecords=");
sb.append(theQuery.displayResults()); sb.append(theQuery.itemsPerPage());
sb.append(ampersand); sb.append(ampersand);
sb.append("resource="); sb.append("resource=");

Loading…
Cancel
Save