R: [opencms-dev] Lucene search How to in Alpaha3

Stefano Suzzi s.suzzi at protesa.it
Mon Jan 24 12:47:24 CET 2005


Here an example how to use the search bean in a jsp.
Hope it helps.
Stefano.

%>
    <jsp:useBean id="search" scope="request"
class="org.opencms.search.CmsSearch">
    <jsp:setProperty name="search" property="*"/>
<% 
    	search.init(cms.getCmsObject()); 
    	search.setIndex("Online project (VFS)"); //here you put your index
name
    	search.setField(new String[] {"title", "keywords", "description",
"content"});
    	search.setMatchesPerPage(10);
    	search.setQueryLength(3);
    	search.setDisplayPages(11);
%>
    </jsp:useBean>

<%
// put the query words in the bean
search.setQuery(Query_string);

// get the search results for the page
result = cms.getSearchResults(search);

if (result == null || result.size() <= 0) {

  if (search.getLastException() != null) { 
%>
    <h3>Errore: sintassi della ricerca non valida.</h3>
    <pre>
<%= search.getLastException().toString() %> 
<%= getStackTrace(search.getLastException()) %> 
    </pre>
<%
  } else {
     out.print("<h3>  Nessuna corrispondenza trovata.</h3>");
  }
} else {	
        // visualizzo i risultati
//        out.println("<h5><font color=\"blue\">Lista risultati per : [" +
search.getQuery() + " ]</font></h5>");

        ListIterator iterator = result.listIterator();

        int n = 0;
        String keyw = "";
        String descr= "";
      
      while (iterator.hasNext()) {
            n++;
            CmsSearchResult entry = (CmsSearchResult)iterator.next();
            keyw = entry.getKeywords();
            descr = entry.getDescription();
%>
................
.........
   <br><strong>Estratto:</strong>         <%= entry.getExcerpt() %>

   <br><strong>Modificato il:</strong> < %= entry.getDateLastModified() % >



-----Messaggio originale-----
Da: Jesus Rodriguez [mailto:rodpemail-opencms at yahoo.es] 
Inviato: venerdì 21 gennaio 2005 15.25
A: opencms-dev at opencms.org
Oggetto: [opencms-dev] Lucene search How to in Alpaha3

Where can I find how to use the lucene search in version 6 alpha3?




More information about the opencms-dev mailing list