<%@page language="java" contentType="text/html; charset=UTF-8" %><%@ page import ="org.apache.lucene.document.Document" %><%@ page import="org.apache.commons.logging.Log" %><%@ page import="org.apache.commons.logging.LogFactory" %><%@ page import="java.util.*" %><%@ page import="java.net.URLEncoder" %><%@ page import="com.eib.search.*" %> <%@ include file="/technical/jsp/common.jsp"%> <% String searchConfig = "/data/www/itf/technical/configuration/search.xml"; int limit=50; Log log = LogFactory.getLog(this.getClass()); String language = null; ResourceBundle i18n = null; String keywords = null; String searchLanguage=null; String simple=null; SearchManager search = null; List hits = null; int nbResults=0; String didYouMean=null; String resLanguage=null; String wordsToSearch = ""; //doit matcher avec le nom des index dans le fichier de conf declare ci-dessus try { request.setCharacterEncoding("UTF-8");//important! language = getLanguage(request); i18n = getI18N(request, language); //Keyword: keywords=request.getParameter("keywords"); try { if (keywords!=null) { keywords = keywords.replace("\"",""); } } catch (Exception e) { log.debug("pb sur le decodage des keywords",e); } //ANTI-SPAM?? //if (keywords!=null && keywords.contains("[url=http://")) { // response.sendError(HttpServletResponse.SC_FORBIDDEN); // return; //} searchLanguage= "en"; log.debug("langue de recherche:" + searchLanguage); //Recherche... search = new SearchManager(searchConfig); String query = new String(); if (keywords!=null && !keywords.equals("") && !keywords.contains("=http://")) { if (!"other".equals(searchLanguage)) { //MyTerm MyTermManager myterm = new MyTermManager(searchConfig); //si plus de 10 mots, on vire les autres car c'est probablement une recherche plus vraiment //pertinente et ça va tout ralentir. String filteredWords = keywords; String[] inputWords = keywords.split(" "); if (inputWords.length > 10) { filteredWords=""; for(int i=0;i<5;i++){ filteredWords+=inputWords[i]+" "; } filteredWords=filteredWords.trim(); } Map> mytermWords = myterm.getTerms(searchLanguage,filteredWords,true); List list = new ArrayList(); for (Language l:mytermWords.keySet()) { for(String word: mytermWords.get(l)) { if (resLanguage==null || resLanguage.equals("") || resLanguage.equals(l.code)) { if (!list.contains(word)) { list.add(word); wordsToSearch+="\"" + word+ "\""+(searchLanguage.equals(l.code)?"^0.5":"^0.1")+" "; log.debug("myterm:"+word); } } } } list.clear(); list=null; } //construction de la requete Lucene //on booste les mots de depart quand meme. String[] words = keywords.split(" "); for (int i=0; i 2) query+=searchWord+" ";//boost ? } if (words.length > 1) { query+="\"" + keywords + "\" ";//on ajoute aussi l'ensemble au cas où cela soit une phrase } //et les autres mots myTerm sans boost query+=wordsToSearch; didYouMean = search.didYouMean(keywords,searchLanguage,"",""); } //lancement de la recherche if (query!=null && query.length()>0) { log.info("[lucene]: [keywords]"+keywords+"[/keywords];query:"+ query.toString()); hits = search.search(query.toString(), (!"other".equals(searchLanguage)?searchLanguage:"en"), null,keywords);//les analysers differents selon la langue, ca marche moyen... } nbResults=0; if (hits!=null) { nbResults=search.getTotalHits(); log.debug(nbResults + " resultats."); } } catch (Exception e) { log.debug("erreur search preamble:",e); } %> Login

Skip to navigation

Skip to content

ITF Home page

Login

You are accessing a restricted area on this website. Please supply the credentials provided to you by the ITF secretariat.

Please contact the ITF secretariat if you cannot login or if you consistently experience problems while logging in.



<% try { //on vire les extentions de language après .htm String actionForm = request.getRequestURI(); try { actionForm = actionForm.substring(0, actionForm.indexOf(".htm")+4); } catch (Exception e) {} String server = request.getServerName(); %>
<%=i18n.getString("searchKeyword")%> " name="keywords" id="keywords" type="text" /> " />
<% if (didYouMean!=null && didYouMean.length() > 0) { String params = "?keywords="+URLEncoder.encode(didYouMean.replace("","").replace("",""),"ISO-8859-1"); %>
<%=i18n.getString("tryWith")%>: <%=didYouMean%>
<% } if (hits!=null) { if (hits.size() <= 0){ out.print(""+ i18n.getString("searchNotFound") + ""); } else { %>

<%=i18n.getString("recordsFound")%> : <%=nbResults%>

Search results

<% for (SearchResult hit : hits){ String url=null; String date=null; String title=null; String summary=null; String ranking =null; String size =null; String hitLanguage = null; String langParam = null; url = hit.getUrl(); date = hit.getDate(); try { title = StringEscapeUtils.escapeXml(hit.getTitle()); } catch (Exception e) {} try { summary = hit.getSummary(); } catch (Exception e) {} try { ranking = Math.round(hit.getScore()*100)+"%"; } catch (NullPointerException npe) {} try { long s = Long.parseLong(hit.getSize()); int ks = (int)s/1024; if (ks > 1024) { float Ms = (float)((int)ks/100)/10; size = Ms +"M"; } else { size = ks +"k"; } } catch (NullPointerException npe) {size=hit.getSize(); } catch (NumberFormatException npe) {size=hit.getSize();} try { hitLanguage=url.substring(url.lastIndexOf(".")+1); if (Arrays.binarySearch(Locale.getISOLanguages(),hitLanguage) < 0) hitLanguage = null; } catch (Exception e) {} try { url = url.replaceAll("\\.htm\\.[a-z]{2}$","\\.htm"); } catch (Exception e) {} try { if (url.endsWith(".htm")) { langParam = "?lang=-"+(hitLanguage!=null?hitLanguage:"en"); } } catch (Exception e) { } %>

"><%=title%>

<% if (summary!=null) { %>
<%=summary%>
<% } %>
  • "><%="http://"+server + url%> <%=(hitLanguage!=null?" - "+hitLanguage:"")%> <% if (date!= null && !date.equals("")) { %> <%=" - " + date%> <% } %> <%=(size != null && !size.equals("")?" - "+size:"")%>
<% } } } %>
<% } catch (Exception e) { log.error("erreur search:",e); } %>