<html><div style='background-color:'><DIV>
<DIV class=RTE>Hello, I have a probleme with lucene, I have this code:</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>String appTitle = "Busqueda Opencms";<BR> String indexLocation = "/lucene/index";<BR> String appfooter = "Jakarta Lucene Template WebApp 1.0";<BR> CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);</DIV>
<DIV class=RTE> String dirParameter = cms.getRequest().getParameter("dir");<BR> </DIV>
<DIV class=RTE> <BR> </DIV>
<DIV class=RTE>%><BR><%-- Zona de configuración --%></DIV>
<DIV class=RTE><%-- Zona de Busqueda --%><BR><center> <BR> <form name="search" action=" <%=cms.getNavigation().getNavigationForResource().getFileName()%> " method="get"><BR> <p class="CampoNoticias"><BR> Criterio de búsqueda <input name="query" size="44"/><BR> </p><BR> <p class="MaximoResultados"><BR> Resultados Máximos por página <input name="maxresults" size="4" value="25"/><BR> <input type="submit" value="Buscar"/><BR> </p><BR> <input type="hidden" name="dir" id="dir" value="<%=dirParameter%>"><BR> <input type="hidden"
name="canalNoticias" id="dir" value="<%=canalNoticias%>"><BR> <input type="hidden" name="canalAgenda" id="dir" value="<%=canalAgenda%>"><BR> </form><BR></center><BR><%-- Zona de Busqueda --%></DIV>
<DIV class=RTE><%-- Zona de resultados --%><BR><%<BR> if ( request.getParameter("query") != null ) // If where are making a query<BR> {<BR> boolean error = false; //used to control flow for error messages<BR> String indexName = indexLocation; //local copy of the configuration variable<BR> IndexSearcher searcher = null; //the searcher used to open/search the index<BR> Query query = null; //the Query
created by the QueryParser<BR> Hits hits = null; //the search results<BR> int startindex = 0; //the first index displayed on this page<BR> int maxpage = 50; //the maximum items displayed on this page<BR> String queryString = null; //the query entered in the previous
page<BR> String startVal = null; //string version of startindex<BR> String maxresults = null; //string version of maxpage<BR> int thispage = 0; //used for the for/next either maxpage
or<BR> //hits.length() - startindex - whichever is<BR> //less</DIV>
<DIV class=RTE> try {<BR> searcher = new IndexSearcher(IndexReader.open(indexName) ); //create an indexSearcher for our page<BR> } catch (Exception e) { //any error that happens is probably due<BR> //to a permission problem or
non-existant<BR> //or otherwise corrupt index<BR>%><BR> <p> ERROR opening the Index - contact sysadmin!</p><BR> <p>Error message: <%=e.getMessage()%></p> <BR><% error =
true; //don't do anything up to the footer<BR> }<BR>%><BR><%<BR> if (error == false) { //did we open the index?<BR> queryString = request.getParameter("query"); //get the search
criteria<BR> startVal = request.getParameter("startat"); //get the start index<BR> maxresults = request.getParameter("maxresults"); //get max results per page<BR> try {<BR> maxpage = Integer.parseInt(maxresults); //parse the max results
first<BR> startindex = Integer.parseInt(startVal); //then the start index <BR> } catch (Exception e) { } //we don't care if something happens we'll just start at 0<BR> //or end at 50</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE> if (queryString == null)<BR> throw new ServletException("no query "+ //if you don't have a query then<BR> "specified"); //you probably played on the
<BR> //query string so you get the <BR> //treatment</DIV>
<DIV class=RTE> Analyzer analyzer = new StopAnalyzer(); //construct our usual analyzer<BR> try {<BR> query = QueryParser.parse(queryString, "contents", analyzer); //parse the <BR> } catch (ParseException e) { //query and construct the
Query<BR> //object<BR> //if it's just "operator
error"<BR> //send them a nice error HTML<BR>
<BR>%><BR> <p>Error while parsing query: <%=e.getMessage()%></p><BR><%<BR> error = true; //don't bother with the rest
of<BR> //the page<BR> }<BR> }<BR>%><BR><%<BR> if (error == false && searcher != null) { // if we've had no
errors<BR> // searcher != null was to handle<BR> // a weird compilation
bug <BR> thispage = maxpage; // default last element to maxpage<BR> hits = searcher.search(query); // run the query <BR> if (hits.length() == 0)
{ // if we got no results tell the user<BR>%><BR> <p> No se ha podido encontrar ningún resultado con la consulta realizada. </p><BR><%<BR> error = true; // don't bother with the rest of
the<BR> // page<BR> <BR> }<BR> }</DIV>
<DIV class=RTE> if (error == false && searcher != null) { <BR>%><BR> <table><BR> <tr><BR> <td class="CampoNoticias">Documento</td><BR> <td
class="CampoNoticias">Sumario</td><BR> </tr><BR><%<BR> if ((startindex + maxpage) > hits.length()) {<BR> thispage = hits.length() - startindex; // set the max index to maxpage or last<BR> } // actual search result whichever is less</DIV>
<DIV class=RTE> for (int i = startindex; i < (thispage + startindex); i++) { // for each element<BR>%><BR> <tr><BR><%<BR> Document doc = hits.doc(i); //get the next document <BR> String doctitle = doc.get("title"); //get its
title<BR> String url = doc.get("url"); //get its url field<BR> if ((doctitle == null) || doctitle.equals("")) //use the url if it has no title<BR> doctitle =
url;<BR> //then output!<BR>%><BR> <td class="MaximoResultados" valign="top"><a href="<%=cms.link("/red" +url.substring(1,url.length()))%>"><%=doctitle%></a></td><BR>
<td class="MaximoResultados" ><%=doc.get("summary")%></td><BR> </tr><BR><%<BR> }<BR>%><BR><% if ( (startindex + maxpage) < hits.length()) { //if there are more results...display <BR> //the more link</DIV>
<DIV class=RTE> String moreurl="buscador.html?query=" + <BR> URLEncoder.encode(queryString) + //construct the "more" link<BR> "&maxresults=" + maxpage +
<BR> "&startat=" + (startindex + maxpage) + <BR> "&dir=" + dirParameter ;<BR>%><BR> <tr><BR> <td></td><td><a href="<%=moreurl%>">Más
Resultados>></a></td><BR> </tr><BR><%<BR> }<BR>%><BR> </table></DIV>
<DIV class=RTE><% } //then include our footer.<BR> }<BR>%><BR><%-- Zona de resultados --%></DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>but en lucene.doc say that I have to put this sentence in console:</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>java org.apache.lucene.demo.IndexHTML -create -index C:\lucene\index C:\Tomcat 5.5\webapps\opencms1\export</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>after create C:\lucene\index and my asks is why not works?</DIV>
<DIV class=RTE>from where have I execute this sentence?(directory)</DIV></DIV></div></html>