<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="javax.servlet.*" import="javax.servlet.http.*" import="java.io.*" import="java.util.*" import="java.net.*" import="org.apache.nutch.html.Entities" import="org.apache.nutch.searcher.*" import="org.apache.nutch.plugin.*" import="org.apache.nutch.clustering.*" import="org.apache.nutch.util.NutchConf" %><%! // NOTE: Dawid Weiss // these are servlet's class variables. Merely to speed up access // to them (instead of referencing static objects). /** * Number of hits to retrieve and cluster if clustering extension is available * and clustering is on. By default, 100. Configurable via nutch-conf.xml. */ private final static int HITS_TO_CLUSTER = NutchConf.get().getInt("extension.clustering.hits-to-cluster", 100); /** * An instance of the clustering extension, if available. */ private static OnlineClusterer clusterer; static { try { clusterer = OnlineClustererFactory.getOnlineClusterer(); } catch (PluginRuntimeException e) { // NOTE: Dawid Weiss // should we ignore plugin exceptions, or rethrow it? Rethrowing // it effectively prevents the servlet class from being loaded into // the JVM } } %> <%-- // Uncomment this to enable query refinement. // Do the same to "refine-query.jsp" below. <%@ include file="./refine-query-init.jsp" %> --%> <% NutchBean bean = NutchBean.get(application); // set the character encoding to use when interpreting request values request.setCharacterEncoding("UTF-8"); bean.LOG.info("query request from " + request.getRemoteAddr()); // get query from request String queryString = request.getParameter("query"); if (queryString == null) { queryString = ""; } String htmlQueryString = Entities.encode(queryString); // a flag to make the code cleaner a bit. boolean clusteringAvailable = (clusterer != null); String clustering = ""; if (clusteringAvailable && "yes".equals(request.getParameter("clustering"))) clustering = "yes"; int start = 0; // first hit to display String startString = request.getParameter("start"); if (startString != null) start = Integer.parseInt(startString); int hitsPerPage = 30; // number of hits to display String hitsString = request.getParameter("hitsPerPage"); if (hitsString != null) hitsPerPage = Integer.parseInt(hitsString); int hitsPerSite =10 ; // max hits per site String hitsPerSiteString = request.getParameter("hitsPerSite"); if (hitsPerSiteString != null) hitsPerSite = Integer.parseInt(hitsPerSiteString); String sort = request.getParameter("sort"); boolean reverse = sort!=null && "true".equals(request.getParameter("reverse")); String params = "&hitsPerPage="+hitsPerPage +(sort==null ? "" : "&sort="+sort+(reverse?"&reverse=true":"")); int hitsToCluster = HITS_TO_CLUSTER; // number of hits to cluster if (queryString.length() > 0) { queryString = "url:www.forschungsportal.ch/unizh " + queryString; } Query query = Query.parse(queryString); bean.LOG.info("query: " + queryString); String language = "en"; ResourceBundle.getBundle("org.nutch.jsp.search", request.getLocale()) .getLocale().getLanguage(); String requestURI = HttpUtils.getRequestURL(request).toString(); String base = requestURI.substring(0, requestURI.lastIndexOf('/')); String rss = "../servlet/opensearch?query="+htmlQueryString +"&hitsPerSite="+hitsPerSite+params; %> <% // To prevent the character encoding declared with 'contentType' page // directive from being overriden by JSTL (apache i18n), we freeze it // by flushing the output buffer. // see http://java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/ out.flush(); %> <%@ taglib uri="http://jakarta.apache.org/taglibs/i18n" prefix="i18n" %> Suche /">

" /> <% if (clusteringAvailable) { %> CHECKED<% } %>> <% } %>

<%-- // Uncomment this to enable query refinement. // Do the same to "refine-query-init.jsp" above. <%@ include file="./refine-query.jsp" %> --%> <% // how many hits to retrieve? if clustering is on and available, // take "hitsToCluster", otherwise just get hitsPerPage int hitsToRetrieve = (clusteringAvailable && clustering.equals("yes") ? hitsToCluster : hitsPerPage); if (clusteringAvailable && clustering.equals("yes")) { bean.LOG.info("Clustering is on, hits to retrieve: " + hitsToRetrieve); } // perform query // NOTE by Dawid Weiss: // The 'clustering' window actually moves with the start // position.... this is good, bad?... ugly?.... Hits hits; try{ hits = bean.search(query, start + hitsToRetrieve, hitsPerSite, "site", sort, reverse); } catch (IOException e){ hits = new Hits(0,new Hit[0]); } int end = (int)Math.min(hits.getLength(), start + hitsPerPage); int length = end-start; int realEnd = (int)Math.min(hits.getLength(), start + hitsToRetrieve); Hit[] show = hits.getHits(start, realEnd-start); HitDetails[] details = bean.getDetails(show); String[] summaries = bean.getSummary(details, query); bean.LOG.info("total hits: " + hits.getTotal()); %> <% if (queryString != "") {%> <% } else { %>

Suchtipps: Die Volltextsuchte umfasst Personen (Projektverantwortliche, Projektleitende und Mitarbeitende) sowie Keywords und Begriffe in Projekttiteln, Abstracts, Publikationslisten etc. Die Projektangaben sind vorwiegend in Englisch erfasst.

Search Tips: The full text search includes people (project leaders, project coordinators, project participants) as well as keywords and specific terms to be found in project titles, abstracts, lists of publications, etc. The project data stored in the database is mainly in English.

<% } %> <% // be responsive out.flush(); %>

<% if (clustering.equals("yes") && length != 0) { %>
<% } %> <% for (int i = 0; i < length; i++) { // display the hits Hit hit = show[i]; HitDetails detail = details[i]; String title = detail.getValue("title"); String url = detail.getValue("url"); if (url.indexOf("forschungsportal") >= 0) url = url.replaceFirst("forschungsportal.ch/unizh", "research-projects.unizh.ch"); String summary = summaries[i]; String id = "idx=" + hit.getIndexNo() + "&id=" + hit.getIndexDocNo(); if (title == null || title.equals("")) // use url for docs w/o title title = url; %> <%=Entities.encode(title)%> <%@ include file="more.jsp" %> <% if (!"".equals(summary)) { %>
<%=summary%> <% } %>
<%=Entities.encode(url)%> <%-- () () () --%> <%-- if (hit.moreFromDupExcluded()) { String more = "query="+URLEncoder.encode("site:"+hit.getDedupValue()+" "+queryString, "utf-8") +params+"&hitsPerSite="+0 +"&clustering="+clustering;%> ( <%=hit.getDedupValue()%>) <% } --%>

<% }%> <% if (clustering.equals("yes") && length != 0) { %>
  <%@ include file="cluster.jsp" %>
<% } %> <% if ((hits.totalIsExact() && end < hits.getTotal()) // more hits to show || (!hits.totalIsExact() && (hits.getLength() > start+hitsPerPage))) { %>
"> <% if (sort != null) { %> <% } %>
<% } if ((!hits.totalIsExact() && (hits.getLength() <= start+hitsPerPage))) { %>
"> <% if (sort != null) { %> <% } %>
<% } %>