You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2005/05/16 00:34:32 UTC

svn commit: r170273 - in /lenya/docu/src/documentation/content: 1_2_x/how-to/search-and-results.xsp 1_2_x/how-to/searchfixer.xsl 1_2_x/how-to/usecase-search.xmap xdocs/1_2_x/how-to/search.xml xdocs/site.xml

Author: gregor
Date: Sun May 15 15:34:30 2005
New Revision: 170273

URL: http://svn.apache.org/viewcvs?rev=170273&view=rev
Log:
Added Paul Ercolino's search how-to.

Added:
    lenya/docu/src/documentation/content/1_2_x/how-to/search-and-results.xsp
    lenya/docu/src/documentation/content/1_2_x/how-to/searchfixer.xsl
    lenya/docu/src/documentation/content/1_2_x/how-to/usecase-search.xmap
    lenya/docu/src/documentation/content/xdocs/1_2_x/how-to/search.xml
Modified:
    lenya/docu/src/documentation/content/xdocs/site.xml

Added: lenya/docu/src/documentation/content/1_2_x/how-to/search-and-results.xsp
URL: http://svn.apache.org/viewcvs/lenya/docu/src/documentation/content/1_2_x/how-to/search-and-results.xsp?rev=170273&view=auto
==============================================================================
--- lenya/docu/src/documentation/content/1_2_x/how-to/search-and-results.xsp (added)
+++ lenya/docu/src/documentation/content/1_2_x/how-to/search-and-results.xsp Sun May 15 15:34:30 2005
@@ -0,0 +1,656 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsp:page language="java"
+  xmlns:xsp="http://apache.org/xsp"
+  xmlns:util="http://apache.org/xsp/util/2.0"
+  xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+>
+  <xsp:structure>
+    <xsp:include>java.io.FileNotFoundException</xsp:include>
+    <xsp:include>java.util.Enumeration</xsp:include>
+    <xsp:include>java.util.HashSet</xsp:include>
+    <xsp:include>java.util.Hashtable</xsp:include>
+    <xsp:include>java.util.Iterator</xsp:include>
+    <xsp:include>java.util.StringTokenizer</xsp:include>
+    <xsp:include>java.util.Vector</xsp:include>
+    <xsp:include>org.apache.avalon.framework.context.ContextException</xsp:include>
+    <xsp:include>org.apache.avalon.framework.component.ComponentException</xsp:include>
+    <xsp:include>org.apache.cocoon.environment.Session</xsp:include>
+    <xsp:include>org.apache.lenya.ac.Accreditable</xsp:include>
+    <xsp:include>org.apache.lenya.ac.Identifiable</xsp:include>
+    <xsp:include>org.apache.lenya.ac.Identity</xsp:include>
+    <xsp:include>org.apache.lenya.lucene.ReTokenizeFile</xsp:include>
+    <xsp:include>org.apache.lenya.lucene.Publication</xsp:include>
+    <xsp:include>org.apache.lucene.analysis.Analyzer</xsp:include>
+    <xsp:include>org.apache.lucene.analysis.standard.StandardAnalyzer</xsp:include>
+    <xsp:include>org.apache.lucene.document.Document</xsp:include>
+    <xsp:include>org.apache.lucene.document.Field</xsp:include>
+    <xsp:include>org.apache.lucene.queryParser.QueryParser</xsp:include>
+    <xsp:include>org.apache.lucene.queryParser.MultiFieldQueryParser</xsp:include>
+    <xsp:include>org.apache.lucene.search.Hits</xsp:include>
+    <xsp:include>org.apache.lucene.search.IndexSearcher</xsp:include>
+    <xsp:include>org.apache.lucene.search.Query</xsp:include>
+    <xsp:include>org.apache.lucene.search.Searcher</xsp:include>
+    <xsp:include>org.apache.lucene.search.Sort</xsp:include>
+  </xsp:structure>
+
+<xsp:logic>
+    File workDir = null;
+    File indexDir=null;
+    File excerptDir=null;
+    String[] fields={"contents","title"};
+    String field = "contents";
+    Vector roles = new Vector();
+    Hashtable protectedAreas = new Hashtable();
+
+    /** 
+     * Contextualize this class 
+     */
+    public void contextualize(Context context) throws ContextException {
+      super.contextualize( context );
+      workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
+    }
+
+    /**
+     * Search index
+     */
+    Hits search(String query_string, String publication_id, String sortField, boolean sortReverse) throws ProcessingException, IOException{
+
+       // Load roles
+       Session session = request.getSession(true);
+       if(session != null){
+          Identity id=(Identity) session.getAttribute("org.apache.lenya.ac.Identity");
+          if(id != null){
+             Identifiable[] ids = id.getIdentifiables();
+             Accreditable[] acs =id.getAccreditables();
+             for (int ai = 0; ai &lt; acs.length; ai++) {
+                boolean found = false;
+                for(int i = 0; i &lt; ids.length; i++){
+                   if(ids[i].toString().equals(acs[ai].toString())){ found = true;}
+                }
+                if(!found){
+                   roles.add(acs[ai].toString());
+                }
+             }
+          }  // id
+       }  // session
+      hits=null;
+      try{
+        Searcher searcher=new IndexSearcher(indexDir.getAbsolutePath());
+        Analyzer l_analyzer=new StandardAnalyzer();
+
+        QueryParser l_queryParser = new QueryParser(field,l_analyzer); // Single field
+        l_queryParser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
+
+        getLogger().debug(query_string);
+        Query l_query = l_queryParser.parse(query_string); // Single field
+
+        if (sortField != null) {
+          Sort sort = new Sort(sortField, sortReverse);
+          hits = searcher.search(l_query, sort);
+        }else{
+          hits = searcher.search(l_query);
+        }
+        if(hits != null){
+          return hits;
+        }
+      }catch(IOException e){
+        System.err.println(".search(): EXCEPTION: "+e);
+        throw e;
+      }catch(Exception e){
+        System.err.println(".search(): EXCEPTION: "+e);
+      }
+      return null;
+   }
+
+   /**
+    *
+    */
+   String getPercent(float score){
+     return ""+java.lang.Math.round(score*100.0);
+   }
+
+   Hits hits;
+   int hits_length=-1;
+
+   String[] words=new String[0];
+
+   int hitsPerPage;
+   int maxPages;
+   int excerptOffset;
+   int start;
+   int end;
+
+</xsp:logic>
+
+  <search-and-results>
+<xsp:logic>
+    // ***********************
+    // *** Protected Areas ***
+    // ***********************
+    // DEFINITION: protectedAreas.add("/UrlStart", "group,group");  
+    // UrlStart begins with / after .../live.
+    // There are no spaces between groups and commas.
+    protectedAreas.put("/employee", "employee");
+
+    // Get sitemap path
+    org.apache.excalibur.source.Source input_source=this.resolver.resolveURI("");
+    String sitemapPath=input_source.getURI();
+    sitemapPath=sitemapPath.substring(5); // Remove "file:" protocol
+
+    // Read parameters from sitemap
+    String numberOfPubs = parameters.getParameter("number-of-pubs", "1");
+    Publication[] pubs = new Publication[Integer.parseInt(numberOfPubs)];
+    for(int i = 0;i &lt; pubs.length;i++) {
+      pubs[i] = new Publication();
+      pubs[i].id = parameters.getParameter("pub"+i+"-id","@ID@");
+      pubs[i].name = parameters.getParameter("pub"+i+"-name","@NAME@");
+      pubs[i].indexDir = parameters.getParameter("pub"+i+"-index-dir","@INDEX-DIR@");
+      pubs[i].searchFields = parameters.getParameter("pub"+i+"-search-fields","title,contents");
+      pubs[i].excerptDir = parameters.getParameter("pub"+i+"-excerpt-dir","@EXCERPT-DIR@");
+      pubs[i].prefix = parameters.getParameter("pub"+i+"-prefix","@PREFIX@");
+    }
+    String param_hits_per_page = parameters.getParameter("max-hits-per-page","13");
+    hitsPerPage = Integer.parseInt(param_hits_per_page);
+    String param_max_pages = parameters.getParameter("max-pages","5");
+    maxPages = Integer.parseInt(param_max_pages);
+    String param_excerpt_offset = parameters.getParameter("excerpt-offset","100");
+    excerptOffset = Integer.parseInt(param_excerpt_offset);
+
+    // Read parameters from query string
+    String urlQuerystring = <xsp-request:get-query-string />;
+    String query = <xsp-request:get-parameter name="query" default=""/>;
+    String publication_id = <xsp-request:get-parameter name="publication-id" default="phlburg"/>;
+    String sortBy = <xsp-request:get-parameter name="sortBy" default="score"/>;
+    String sortReverse = <xsp-request:get-parameter name="sortReverse" default="false"/>;
+
+    String language = "";
+    StringTokenizer qsTokens = new StringTokenizer(urlQuerystring, "&amp;&#061;", true);
+    String token = "";
+    HashSet languageSet = new HashSet();
+    if(qsTokens.hasMoreTokens()){ token = qsTokens.nextToken(); }
+    while(qsTokens.hasMoreTokens()){
+       if(token.equalsIgnoreCase("language")){ 
+          token = qsTokens.nextToken();
+          if(token.equals("=") &amp;&amp; qsTokens.hasMoreTokens()){
+             languageSet.add(qsTokens.nextToken());
+          }
+       }else{
+          token = qsTokens.nextToken();
+       }
+    }
+    Iterator languageSetItems = languageSet.iterator();
+    if(languageSetItems.hasNext()){ language = languageSetItems.next().toString(); }
+    while(languageSetItems.hasNext()){ language += "," + languageSetItems.next().toString(); }
+    if(language.length() == 0) language = "en";
+
+    String startString = <xsp-request:get-parameter name="start" default="1"/>;
+    String endString = <xsp-request:get-parameter name="end" default="10"/>;
+    start=new Integer(startString).intValue();
+    if(endString == null){
+      end=hitsPerPage;
+    }else{
+      end=new Integer(endString).intValue();
+    }
+
+    // Find the number of the selected publication
+    int whichPublication=0;
+    for (int i = 0;i &lt; pubs.length;i++) {
+      if (pubs[i].id.equals(publication_id)) {
+        whichPublication = i;
+      }
+    }
+
+    // Get all search fields
+    Vector twords = null;
+    Vector myFields = new Vector();
+    Enumeration parameterNames = request.getParameterNames();
+    while(parameterNames.hasMoreElements()){
+       String parameterName=(String)parameterNames.nextElement();
+       String value=request.getParameter(parameterName);
+
+       if (parameterName.indexOf(".fields") > 0) { // looking for field parameters
+          StringTokenizer st = new StringTokenizer(parameterName, ".");
+          int length = st.countTokens();
+          if(st.hasMoreTokens()){
+             String fieldPublicationId = st.nextToken();
+             if(st.hasMoreTokens()){
+                if(fieldPublicationId.equals(publication_id) || fieldPublicationId.equals("dummy-index-id")) {
+                   st.nextToken(); // Ignore "fields" token
+                   if(length == 2) { // radio or select
+                      myFields.addElement(value);
+                   }else if (length == 3) { // checkbox
+                      myFields.addElement(st.nextToken());
+                   }else{
+                      // something is wrong
+                   }
+                }
+             }
+          }
+       }
+    }
+    if(myFields.size() > 0) {
+       field = (String)myFields.elementAt(0);
+       fields = new String[myFields.size()];
+       for(int i = 0; i &lt; myFields.size(); i++) {
+          fields[i] = (String)myFields.elementAt(i);
+       }
+     }
+     // Set index and excerpt dir
+     String param_index_dir=pubs[whichPublication].indexDir;
+     if(param_index_dir.charAt(0) == '/'){
+        indexDir=new File(param_index_dir);
+        }
+     else{
+        indexDir=new File(sitemapPath+File.separator+param_index_dir);
+        }
+     String param_excerpt_dir=pubs[whichPublication].excerptDir;
+     if(param_excerpt_dir.charAt(0) == '/'){
+        excerptDir=new File(param_excerpt_dir);
+     }else{
+        excerptDir=new File(sitemapPath+File.separator+param_excerpt_dir);
+     }
+</xsp:logic>
+    <configuration><xsp:attribute name="checked-pid"><xsp:expr>publication_id</xsp:expr></xsp:attribute>
+      <number-of-publications><xsp:expr>numberOfPubs</xsp:expr></number-of-publications>
+
+<xsp:logic>
+      for(int i = 0;i &lt; pubs.length;i++) {
+</xsp:logic>
+         <publication><xsp:attribute name="pid"><xsp:expr>pubs[i].id</xsp:expr></xsp:attribute>
+           <name><xsp:expr>pubs[i].name</xsp:expr></name>
+           <index-dir><xsp:expr>pubs[i].indexDir</xsp:expr></index-dir>
+           <search-fields>
+<xsp:logic>
+               String[] searchFields = pubs[i].getFields();
+               if (searchFields != null) {
+                   for (int k = 0; k &lt; searchFields.length; k++) {
+                       <field><xsp:expr>searchFields[k]</xsp:expr></field>
+                   }
+               } else {
+</xsp:logic>
+                   <xsp:content><xsp:expr>pubs[i].searchFields</xsp:expr></xsp:content><exception>.getFields() returned null</exception>
+<xsp:logic>
+               }
+</xsp:logic>
+           </search-fields>
+           <excerpt-dir><xsp:expr>pubs[i].excerptDir</xsp:expr></excerpt-dir>
+           <prefix><xsp:expr>pubs[i].prefix</xsp:expr></prefix>
+         </publication>
+<xsp:logic>
+      }
+</xsp:logic>
+      <hits-per-page><xsp:expr>hitsPerPage</xsp:expr></hits-per-page>
+      <max-pages><xsp:expr>maxPages</xsp:expr></max-pages>
+      <excerpt-offset><xsp:expr>excerptOffset</xsp:expr></excerpt-offset>
+    </configuration>
+
+<!-- Search Results -->
+      <search>
+<xsp:logic>
+          Enumeration para_names = request.getParameterNames();
+          if(para_names.hasMoreElements()){
+</xsp:logic>
+            <request-parameters>
+<xsp:logic>
+              while(para_names.hasMoreElements()){
+                String para_name=(String)para_names.nextElement();
+                String para_value=request.getParameter(para_name);
+</xsp:logic>
+                <parameter><xsp:attribute name="name"><xsp:expr>para_name</xsp:expr></xsp:attribute><xsp:attribute name="value"><xsp:expr>para_value</xsp:expr></xsp:attribute></parameter>
+                <xsp:element><xsp:param name="name"><xsp:expr>para_name</xsp:expr></xsp:param><xsp:expr>para_value</xsp:expr></xsp:element>
+<xsp:logic>
+                }
+</xsp:logic>
+            </request-parameters>
+<xsp:logic>
+            }
+          if(query != null &amp;&amp; query.length() != 0 &amp;&amp; publication_id != null &amp;&amp; publication_id.length() > 0){
+
+            try {
+                if (sortBy.equals("score")) {
+                   hits = search(query, publication_id, null, false);
+                } else {
+                   if (sortReverse.equals("true")) {
+                       hits = search(query, publication_id, sortBy, true);
+                   } else {
+                       hits = search(query, publication_id, sortBy, false);
+                   }
+                }
+            } catch(Exception e) {
+</xsp:logic>
+                <exception><xsp:expr>e.toString()</xsp:expr></exception>
+<xsp:logic>
+            }
+            if(hits != null){
+              hits_length=hits.length();
+              }
+            else{
+              hits_length=-1;
+              hits=null;
+              }
+</xsp:logic>
+            <publication-id><xsp:expr>publication_id</xsp:expr></publication-id>
+            <publication-name><xsp:expr>pubs[whichPublication].name</xsp:expr></publication-name>
+            <publication-prefix><xsp:expr>pubs[whichPublication].prefix</xsp:expr></publication-prefix>
+            <sort-by><xsp:expr>sortBy</xsp:expr></sort-by>
+            <query><xsp:expr>query</xsp:expr></query>
+<xsp:logic>
+            if(query != null){
+              twords = new Vector();
+</xsp:logic>
+              <words>
+<xsp:logic>
+              StringTokenizer st=new StringTokenizer(query," ");
+              while(st.hasMoreTokens()){
+                String word=(String)st.nextElement();
+                if(!(word.equalsIgnoreCase("OR") || word.equalsIgnoreCase("AND"))){
+                  <word><xsp:expr>word</xsp:expr></word>
+                  twords.addElement(word);
+                  }
+                }
+              words=new String[twords.size()];
+              for(int i=0;i&lt;twords.size();i++){
+                words[i]=(String)twords.elementAt(i);
+              }
+</xsp:logic>
+              </words>
+<xsp:logic>
+              }
+</xsp:logic>
+            <start><xsp:expr>start</xsp:expr></start>
+            <end><xsp:expr>end</xsp:expr></end>
+            <language><xsp:expr>language</xsp:expr></language>
+            <fields>
+<xsp:logic>
+              for (int i = 0; i &lt; fields.length; i++) {
+                <field><xsp:expr>fields[i]</xsp:expr></field>
+              }
+</xsp:logic>
+            </fields>
+<xsp:logic>
+      try{
+        Analyzer ll_analyzer=new StandardAnalyzer();
+        QueryParser queryParser = new QueryParser(field,ll_analyzer);
+        //MultiFieldQueryParser queryParser = new MultiFieldQueryParser("contents",ll_analyzer);
+        queryParser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
+        Query ll_query = queryParser.parse(query);
+        //Query ll_query = queryParser.parse(query,fields,ll_analyzer);
+        <query><xsp:expr>ll_query.toString("contents")</xsp:expr></query>
+        }
+      catch(Exception e){
+        <exception><xsp:expr>e.toString()</xsp:expr></exception>
+        }
+            }
+          else{
+            hits_length=-1;
+            hits=null;
+            }
+</xsp:logic>
+      </search>
+<xsp:logic>
+            if(hits != null){
+    int validCount = 0;  //number of valid results
+</xsp:logic>
+        <results>
+<xsp:logic>
+       if(hits_length &gt; 0){
+</xsp:logic>
+     <hits>
+<xsp:logic>
+// i = index of result.  validCount = count valid results.
+for (int i = 0; (i &lt; hits.length()); i++) {
+                Document ldoc=hits.doc(i);
+                Enumeration lfields = ldoc.fields();
+                String lpath=ldoc.get("path");
+
+                String lurl=ldoc.get("url");
+                String ltitle=ldoc.get("title");
+                String mime_type=ldoc.get("mime-type");
+                String docLanguage = "";
+                if(lpath != null){
+</xsp:logic>
+                  <hit>
+                    <score><xsp:attribute name="percent"><xsp:expr>getPercent(hits.score(i))</xsp:expr></xsp:attribute>
+                    <xsp:expr>hits.score(i)</xsp:expr></score> 
+                    <path><xsp:expr>lpath</xsp:expr></path>
+                  </hit>
+<xsp:logic>
+                }
+                else if(lurl != null){
+                   // Check Language
+                   // This also filters sitetree.xml since it has no language.
+                   docLanguage = "";
+                   while (lfields.hasMoreElements()) {
+                      Field lfield = (Field)lfields.nextElement();
+			    if(0 == lfield.name().compareTo("language")){
+                         docLanguage = lfield.stringValue();
+			    }
+                   }
+</xsp:logic>
+<language><xsp:expr>language</xsp:expr></language>
+<language-check><xsp:attribute name="doc"><xsp:expr>docLanguage</xsp:expr></xsp:attribute></language-check>
+<xsp:logic>
+                   if((docLanguage.length() > 0) &amp;&amp; (language.indexOf(docLanguage) != -1)){
+</xsp:logic>
+<language-yes/>
+<xsp:logic>
+                      // Get URL parts
+                      String parent = "";
+                      String filename = "";
+                      String querystring = "";
+                      if(lurl.lastIndexOf("/") &gt; -1) {
+                          parent = lurl.substring(0,lurl.lastIndexOf("/"));
+                          filename = lurl.substring(lurl.lastIndexOf("/")+1);
+                      }
+                      if(lurl.indexOf("?") &gt; -1) {
+                          querystring = lurl.substring(lurl.indexOf("?"));
+                      }
+                      // Check Restricted
+                      boolean restricted = false;
+                      // Get list of restricted prefixes and check against roles.
+                      Enumeration protectedArea = protectedAreas.keys();
+                      while((!restricted) &amp;&amp; protectedArea.hasMoreElements()){
+                         String startUrl = (String) protectedArea.nextElement();
+                         if(parent.startsWith(startUrl)){
+                            StringTokenizer rolesAllowed = new StringTokenizer((String)protectedAreas.get(startUrl), ",");
+                            restricted = true; 
+                            while(rolesAllowed.hasMoreElements()){
+                      // Check roles
+                               if(roles.contains(rolesAllowed.nextElement())){
+                                  restricted = false;
+                               }
+                            }
+                         }
+                      }
+                      if(!restricted){
+                         // Build hit
+                         validCount++;
+                         if((validCount &gt;= start) &amp;&amp; (validCount &lt;= end)){
+</xsp:logic>
+                  <hit><xsp:attribute name="pos"><xsp:expr>validCount</xsp:expr></xsp:attribute>
+                    <fields>
+<xsp:logic>
+                    lfields = ldoc.fields();
+                    int first = -1;
+                    while (lfields.hasMoreElements()) {
+                       Field lfield = (Field)lfields.nextElement();
+                       String slfield = lfield.stringValue();
+
+                       if(lfield.name().equals("htmlbody")){
+                          String tmphtmlbody = slfield;
+                          String upperhtmlbody = tmphtmlbody.toUpperCase();
+                          if(twords != null){
+                             Enumeration twordsE = twords.elements();
+                             while(twordsE.hasMoreElements()){
+                                int last = 0;
+                                String word = twordsE.nextElement().toString();
+                                String upperword = word.toUpperCase();
+                                int wordLen = word.length();
+                                StringBuffer sb = new StringBuffer();
+                                int current = upperhtmlbody.indexOf(upperword);
+                                if((current &lt; first) || (first == -1)) first = current;
+                                while(current &gt; last){
+                                   sb.append(tmphtmlbody.substring(last, current));
+                                   sb.append("~").append(tmphtmlbody.substring(current, current + wordLen)).append("~");
+                                   last = current + wordLen;
+                                   current = upperhtmlbody.indexOf(upperword, last);
+                                }
+                                sb.append(tmphtmlbody.substring(last));
+                                tmphtmlbody = sb.toString();
+                                upperhtmlbody = tmphtmlbody.toUpperCase();
+                             }
+                          }
+                          if(slfield.length() &gt; excerptOffset){
+                             int start = 0;
+                             int end = excerptOffset;
+                             int half = excerptOffset/2;
+                             if(first &lt; half){
+                                end = tmphtmlbody.indexOf(' ', excerptOffset);
+                             }else{
+                                start = tmphtmlbody.indexOf(' ', first - half);
+                                end = tmphtmlbody.indexOf(' ', start + excerptOffset);
+                             }
+                             tmphtmlbody = tmphtmlbody.substring(start, end);
+                          }
+                          StringTokenizer tokens = new StringTokenizer(tmphtmlbody, "~");
+                          boolean needCloseHtmlBody = false;
+                          if(tokens.hasMoreTokens()){
+                          needCloseHtmlBody = true;
+</xsp:logic>
+                             <htmlbody><xsp:expr>tokens.nextToken()</xsp:expr>
+<xsp:logic>
+                          }
+                          while(tokens.hasMoreTokens()){
+</xsp:logic>
+                             <word><xsp:expr>tokens.nextToken()</xsp:expr></word>
+<xsp:logic>
+                             if(tokens.hasMoreTokens()){
+</xsp:logic>
+                                <xsp:expr>tokens.nextToken()</xsp:expr>
+<xsp:logic>
+                             }
+                          }
+                          if(needCloseHtmlBody){
+</xsp:logic>
+                             </htmlbody>
+<xsp:logic>
+                          }
+                       }else{
+
+</xsp:logic>
+                        <xsp:element><xsp:param name="name"><xsp:expr>lfield.name()</xsp:expr></xsp:param><xsp:expr>slfield</xsp:expr></xsp:element>
+<xsp:logic>
+                       }
+                    }
+
+</xsp:logic>
+                    </fields>
+                    <score><xsp:attribute name="percent"><xsp:expr>getPercent(hits.score(i))</xsp:expr></xsp:attribute><xsp:expr>hits.score(i)</xsp:expr></score> 
+                    <uri>
+                      <xsp:attribute name="parent"><xsp:expr>parent</xsp:expr></xsp:attribute>
+                      <xsp:attribute name="filename"><xsp:expr>filename</xsp:expr></xsp:attribute>
+                      <xsp:attribute name="querystring"><xsp:expr>querystring</xsp:expr></xsp:attribute>
+                      <xsp:expr>lurl</xsp:expr>
+                    </uri>
+<xsp:logic>
+                    File excerptFile=new File(excerptDir+File.separator+lurl);
+                    if((ltitle != null) &amp;&amp; (ltitle.length() &gt; 0)){
+                      <title><xsp:expr>ltitle</xsp:expr></title>
+                    }else{
+                      <title><xsp:expr>excerptFile.getName()</xsp:expr></title>
+                      <no-title/>
+                    }
+                    if((mime_type != null) &amp;&amp; (mime_type.length() &gt; 0)){
+                      <mime-type><xsp:expr>mime_type</xsp:expr></mime-type>
+                    }else{
+                      <no-mime-type/>
+                    }
+                    try{
+                      ReTokenizeFile rtf=new ReTokenizeFile();
+                      rtf.setOffset(excerptOffset);
+                      String excerpt=rtf.getExcerpt(excerptFile,words);
+                      if(excerpt != null){
+                        excerpt=rtf.emphasizeAsXML(rtf.tidy(excerpt),words);
+                        <util:include-expr><util:expr><xsp:expr>excerpt</xsp:expr></util:expr></util:include-expr>
+                      }else{
+                        throw new Exception("excerpt == null. Maybe file does not contain the words!");
+                        }
+                      }
+                    catch(FileNotFoundException e){
+</xsp:logic>
+                      <no-excerpt>
+                      <file><xsp:attribute name="src"><xsp:expr>excerptFile.getAbsolutePath()+" "+words[0]+" "+e</xsp:expr></xsp:attribute></file>
+                      </no-excerpt>
+<xsp:logic>
+                      }
+                    catch(Exception e){
+                      <excerpt-exception><xsp:expr>""+e</xsp:expr></excerpt-exception>
+                      }
+</xsp:logic>
+                  </hit>
+<xsp:logic>
+                 }
+} // END - Within range (start-end)
+} // END - Check Restricted
+} // END - Check Language
+             }
+</xsp:logic>
+     </hits>
+<xsp:logic>
+        }else{
+</xsp:logic>
+       <no-hits/>
+<xsp:logic>
+        }
+             int number_of_pages=(validCount/hitsPerPage);
+             if(number_of_pages*hitsPerPage != validCount){
+               number_of_pages=number_of_pages+1;
+               }
+             if(number_of_pages &gt; maxPages){
+               number_of_pages=maxPages;
+               }
+             if(validCount == 0){
+               number_of_pages=0;
+               <no-pages/>
+               }
+             else{
+</xsp:logic>
+             <pages>
+<xsp:logic>
+             for(int i=0;i&lt;number_of_pages;i++){
+               int pstart=i*hitsPerPage+1;
+               int pend=(i+1)*hitsPerPage;
+               if(validCount &lt; pend){
+                 pend=validCount;
+                 }
+               String type="other";
+               if(pstart == start){
+                 type="current";
+                 }
+               else if(pstart == start-hitsPerPage){
+                 type="previous";
+                 }
+               else if(pstart == start+hitsPerPage){
+                 type="next";
+                 }
+</xsp:logic>
+               <page>
+                 <xsp:attribute name="start"><xsp:expr>pstart</xsp:expr></xsp:attribute>
+                 <xsp:attribute name="end"><xsp:expr>pend</xsp:expr></xsp:attribute>
+                 <xsp:attribute name="type"><xsp:expr>type</xsp:expr></xsp:attribute>
+               </page>
+<xsp:logic>
+              }
+</xsp:logic>
+             </pages>
+<xsp:logic>
+             }
+</xsp:logic>
+<total-hits><xsp:expr>validCount</xsp:expr></total-hits>
+        </results>
+<xsp:logic>
+            }
+</xsp:logic>
+   </search-and-results>
+</xsp:page>
+

Added: lenya/docu/src/documentation/content/1_2_x/how-to/searchfixer.xsl
URL: http://svn.apache.org/viewcvs/lenya/docu/src/documentation/content/1_2_x/how-to/searchfixer.xsl?rev=170273&view=auto
==============================================================================
--- lenya/docu/src/documentation/content/1_2_x/how-to/searchfixer.xsl (added)
+++ lenya/docu/src/documentation/content/1_2_x/how-to/searchfixer.xsl Sun May 15 15:34:30 2005
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" 
+    xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0" 
+    xmlns:session="http://www.apache.org/xsp/session/2.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+    <xsl:param name="area" select="'live'"/>
+
+<xsl:variable name="pubid">
+<xsl:value-of select="search-and-results/configuration/publication/name" />
+</xsl:variable>
+
+
+    <xsl:template match="search-results">
+        <xsl:apply-templates select="search-and-results"/>
+    </xsl:template>
+
+    <xsl:template match="search-and-results">
+       <search-and-results>
+         <configuration>
+           <xsl:apply-templates select="configuration"/>
+         </configuration>
+         <xsl:apply-templates select="search"/>
+         <xsl:apply-templates select="results"/>
+       </search-and-results>
+    </xsl:template>
+    
+    <xsl:template match="configuration">
+        <xsl:apply-templates/>
+        <xsl:apply-templates select="//search-results/publication/languages" />
+    </xsl:template>
+
+    <xsl:template match="languages">
+        <languages>
+           <xsl:apply-templates select="language"/>
+        </languages>
+    </xsl:template>
+
+    <xsl:template match="results">
+         <results total-hits="{total-hits}">
+           <xsl:apply-templates select="pages"/>
+           <xsl:apply-templates select="hits"/>
+         </results>
+    </xsl:template>
+
+    <xsl:template match="hits">
+       <hits>
+          <xsl:apply-templates select="hit"/>
+      </hits>
+    </xsl:template>
+
+    <xsl:template match="hit">
+       <xsl:if test="uri[@filename != 'sitetree.xml']">
+          <hit pos="{@pos}">
+             <xsl:apply-templates select="score"/>
+             <xsl:apply-templates select="uri"/>
+<title>
+<xsl:choose>
+<xsl:when test="string-length(fields/title) &gt; 0"><xsl:value-of select="fields/title"/></xsl:when>
+<xsl:when test="string-length(fields/htmltitle) &gt; 0"><xsl:value-of select="fields/htmltitle"/></xsl:when>
+<xsl:when test="string-length(title) &gt; 0"><xsl:value-of select="title"/></xsl:when>
+<xsl:otherwise>Untitled</xsl:otherwise>
+</xsl:choose>
+</title>
+
+<!--             <xsl:apply-templates select="excerpt"/>   Lucene Excerpt -->
+<!--             <xsl:apply-templates select="fields/description"/> Lenya Description -->
+             <xsl:apply-templates select="fields/htmlbody"/> <!-- HTML Body -->
+          </hit>
+       </xsl:if>
+    </xsl:template>
+    
+    <xsl:template match="uri">
+ <uri><xsl:value-of select="$pubid"/><xsl:value-of select="@parent"/>_<xsl:value-of select="../fields/language"/>.html</uri>
+    </xsl:template>
+    
+    <xsl:template match="description">
+        <excerpt><xsl:value-of select="."/></excerpt>
+    </xsl:template>
+    <xsl:template match="htmlbody">
+        <excerpt><xsl:apply-templates/></excerpt>
+    </xsl:template>
+
+    <xsl:template match="@*|node()" priority="-1">
+        <xsl:copy>
+            <xsl:apply-templates select="@*|node()"/>
+        </xsl:copy>
+    </xsl:template>
+</xsl:stylesheet>

Added: lenya/docu/src/documentation/content/1_2_x/how-to/usecase-search.xmap
URL: http://svn.apache.org/viewcvs/lenya/docu/src/documentation/content/1_2_x/how-to/usecase-search.xmap?rev=170273&view=auto
==============================================================================
--- lenya/docu/src/documentation/content/1_2_x/how-to/usecase-search.xmap (added)
+++ lenya/docu/src/documentation/content/1_2_x/how-to/usecase-search.xmap Sun May 15 15:34:30 2005
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+
+<!-- =========================== Components ================================ -->
+   <map:components>
+      <map:generators default="file"/>
+      <map:transformers default="xalan"/>
+      <map:readers default="resource"/>
+      <map:serializers default="xhtml"/>
+      <map:matchers default="wildcard"/>
+      <map:actions/>
+      <map:selectors>
+         <map:selector name="request-method" logger="sitemap.selector.request-method" src="org.apache.cocoon.selection.RequestMethodSelector"/>
+       </map:selectors>
+   </map:components>
+
+  <map:resources>
+      <map:resource name="finish">
+           <map:transform type="i18n">
+              <map:parameter name="locale" value="{page-envelope:document-language}"/>
+           </map:transform>
+           <map:transform src="../../xslt/util/strip_namespaces.xsl"/>
+           <map:select type="parameter">
+              <map:parameter name="statusCode" value="{statusCode}"/>
+              <map:when test="">
+                <map:serialize type="html" />
+              </map:when>
+              <map:otherwise>
+                <map:serialize type="html" status-code="{statusCode}"/>
+              </map:otherwise>
+           </map:select>
+      </map:resource>
+
+      <map:resource name="page-xhtml">
+           <map:transform src="xslt/page2xhtml.xsl">
+              <map:parameter name="root" value="/{page-envelope:publication-id}/live"/>
+              <map:parameter name="document-id" value="/index"/>
+              <map:parameter name="url" value="live/index.html"/>
+              <map:parameter name="language" value="{page-envelope:document-language}"/>
+              <map:parameter name="showLogin" value="1"/>
+              <map:parameter name="showFav" value="0"/>
+              <map:parameter name="querystring" value="{request:queryString}"/>
+           </map:transform>
+      </map:resource>
+  </map:resources>
+
+<!-- =========================== Pipelines ================================ -->
+   <map:pipelines>
+      <map:pipeline>
+      <map:match pattern="*/search-*/lucene.xml">
+        <map:generate type="serverpages" src="lenya/content/search/search-and-results.xsp" label="xml">
+          <map:parameter name="max-hits-per-page" value="10"/>
+          <map:parameter name="max-pages" value="10"/>
+          <map:parameter name="excerpt-offset" value="150"/>
+          <map:parameter name="number-of-pubs" value="1"/>
+          <map:parameter name="pub0-id" value="{page-envelope:publication-id}"/>
+          <map:parameter name="pub0-name" value="{page-envelope:publication}"/>
+          <map:parameter name="pub0-index-dir" value="./work/search/lucene/index/{2}/index"/>
+          <map:parameter name="pub0-search-fields" value="contents,title"/>
+          <map:parameter name="pub0-excerpt-dir" value="./content/{2}"/>
+          <map:parameter name="pub0-prefix" value=""/>
+        </map:generate>
+        <map:serialize type="xml"/>
+      </map:match>
+
+      <map:match pattern="search-page">
+        <map:aggregate element="search-results">
+          <map:part src="./config/publication.xconf"/>
+          <map:part src="cocoon:/{page-envelope:publication-id}/search-live/lucene.xml?{request:queryString}"/>
+        </map:aggregate>
+        <map:transform src="xslt/search/searchfixer.xsl">
+            <map:parameter name="area" value="live"/>
+        </map:transform>
+        <map:transform src="xslt/search/sort.xsl"/>
+        <map:act type="resource-exists" src="xslt/search/search-and-results-body.xsl">
+          <map:transform src="lenya/xslt/search/search-and-results-body.xsl">
+            <map:parameter name="contextprefix" value="{request:contextPath}"/>
+            <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
+            <map:parameter name="area" value="live"/>
+          </map:transform>
+        </map:act>
+        <map:transform src="xslt/search/search-and-results.xsl">
+            <map:parameter name="contextprefix" value="{request:contextPath}"/>
+            <map:parameter name="publicationid" value="{page-envelope:publication-id}"/>
+            <map:parameter name="area" value="live"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
+     <map:match type="usecase" pattern="search">
+        <map:aggregate element="cmsbody">
+          <map:part src="cocoon://navigation/{page-envelope:publication-id}/live/breadcrumb/live/index.xml"/>
+          <map:part src="cocoon://navigation/{page-envelope:publication-id}/live/tabs/index.xml"/>
+          <map:part src="cocoon://navigation/{page-envelope:publication-id}/live/menu/index.xml" prefix="xhtml"/>
+          <map:part src="cocoon://navigation/{page-envelope:publication-id}/live/search/index.xml"/>
+          <map:part src="cocoon:/search-page"/>
+        </map:aggregate>
+        <map:call resource="page-xhtml"/>
+        <map:call resource="finish"/>
+      </map:match>
+
+    </map:pipeline>
+  </map:pipelines>
+</map:sitemap>

Added: lenya/docu/src/documentation/content/xdocs/1_2_x/how-to/search.xml
URL: http://svn.apache.org/viewcvs/lenya/docu/src/documentation/content/xdocs/1_2_x/how-to/search.xml?rev=170273&view=auto
==============================================================================
--- lenya/docu/src/documentation/content/xdocs/1_2_x/how-to/search.xml (added)
+++ lenya/docu/src/documentation/content/xdocs/1_2_x/how-to/search.xml Sun May 15 15:34:30 2005
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed under the Apache License, Version 1.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-1.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: index.xml 55543 2004-10-26 00:14:59Z gregor $ -->
+
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
+
+<document>
+  <header>
+    <title>Searching Publications How-To</title>
+  </header>
+    <body>
+    <section><title>Introduction</title>
+            <p>This article has 4 goals:</p>
+            <ol>
+            <li>Complete instructions for indexing on Windows.</li>
+            <li>Display search with a publication's layout rather than the global layout.</li>
+            <li> Filter out a Member's Only area from the results.</li>
+            <li> Fix poor design decisions and bugs.</li>
+            </ol>
+            <p>Changes include:</p>
+            <ol>
+            <li> Index live XML files.<br/>The standard method crawls the site, putting the results into the  "htdocs_dump" directory. The index is built from there. The index will not include documents not accessible from the start page, such as Members' Only sections. The index also include navigation menus.<br/>Using the XML files indexes all content, whether accessible or not, and does not index the site architecture. If a visitor searches on "search", they should receive documents including the word "search", not every page with the search function (which should be every page in a well-designed website).<br/>The index still includes everything in a document including header information such as author. It is easy to limit the index to the content body, but that could cause complications when using non-standard Lenya documents (Custom DocTypes/Resource Types). If Custom Doctypes are used, modify searchfixer.xsl (see below). <strong>Custom Doctypes were not tested with this configuration.</strong></li>
+            
+            <li> Remove "Members' Only" documents if not authorized. Visitors must be logged in and in one of the specified Goups. It is the reverse of the current Lenya security, since deep URLs must pass the test for all parents. Example: /employees/programmers must pass tests for both the "/employees" and "/employees/programmers" sections.</li>
+            
+            <li> Add language to the index.</li>
+            <li> Limit initial search to current language.</li>
+            <li> Search page: Remove choice of publications. (This is a design decision. One publication = one website. With protected areas, there should be no need for multiple publications.)</li>
+            <li> Search page: Filter by chosen languages.</li>
+            <li> Default to search "Content", not "Title".</li>
+            <li> Increase the default results per page from 3 to 10.</li></ol>
+            
+            <p>NOTE: Replace {pub} with your publication name in all instructions.</p>
+            </section>
+            <section><title>Indexing on Windows</title>
+            <p>This assumes Lenya 1.2.2 was installed to C:\apache-lenya-1.2.2 If your installation is different, adjust the paths. The indexer adds namespaces to the data of Fields in the index. The namespaces are not used (and are annoying), so remove them. An alternative is to fix the XML later, but why bother? File: <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\WEB-INF\classes\org\apache\lenya\lucene\index\configuration2xslt.xsl</tt> Add the following line:</p>
+            <source>&lt;xsl:template match="namespace"/&gt;</source>
+            <ol><li>Set the configuration by changing: <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\config\search\lucene-live.xconf</tt>
+            To:
+            <source>
+            &lt;?xml version="1.0"?&gt;
+             &lt;lucene&gt;
+                 &lt;update-index type="new"/&gt;
+                 &lt;index-dir src="../../work/search/lucene/index/live/index"/&gt;
+                 &lt;htdocs-dump-dir src="../../content/live"/&gt;
+                 &lt;indexer class="org.apache.lenya.lucene.index.ConfigurableIndexer"&gt;
+                     &lt;configuration src="lenyadocs.xconf"/&gt;
+                     &lt;extensions src="xml"/&gt;
+                 &lt;/indexer&gt;
+             &lt;/lucene&gt;</source></li>
+            <li> Create a new file in the same directory to tell lucene what fields to index (filename must match the configuration src in lucene-live.xconf): <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\config\search\lenyadocs.xconf</tt>
+            Add this:
+            <source>&lt;?xml version="1.0"?&gt;
+             &lt;luc:document xmlns:luc="http://apache.org/cocoon/lenya/lucene/1.0"&gt;
+             &lt;luc:field name="title" type="Text"&gt;
+                 &lt;namespace prefix="lenya"&gt;http://apache.org/cocoon/lenya/page-envelope/1.0&lt;/namespace&gt;
+                 &lt;namespace prefix="dc"&gt;http://purl.org/dc/elements/1.1/&lt;/namespace&gt;
+                 &lt;xpath&gt;/*/lenya:meta/dc:subject&lt;/xpath&gt;
+             &lt;/luc:field&gt;
+             &lt;luc:field name="htmltitle" type="Text"&gt;
+                 &lt;namespace prefix="xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/namespace&gt;
+                 &lt;xpath&gt;/xhtml:html/xhtml:head/xhtml:title&lt;/xpath&gt;
+             &lt;/luc:field&gt;
+             &lt;luc:field name="language" type="Text"&gt;
+                 &lt;namespace prefix="lenya"&gt;http://apache.org/cocoon/lenya/page-envelope/1.0&lt;/namespace&gt;
+                 &lt;namespace prefix="dc"&gt;http://purl.org/dc/elements/1.1/&lt;/namespace&gt;
+                 &lt;xpath&gt;/*/lenya:meta/dc:language&lt;/xpath&gt;
+             &lt;/luc:field&gt;
+             &lt;luc:field name="description" type="Text"&gt;
+                 &lt;namespace prefix="lenya"&gt;http://apache.org/cocoon/lenya/page-envelope/1.0&lt;/namespace&gt;
+                 &lt;namespace prefix="dc"&gt;http://purl.org/dc/elements/1.1/&lt;/namespace&gt;
+                 &lt;xpath&gt;/*/lenya:meta/dc:description&lt;/xpath&gt;
+             &lt;/luc:field&gt;
+             &lt;luc:field name="htmlbody" type="Text"&gt;
+                 &lt;namespace prefix="xhtml"&gt;http://www.w3.org/1999/xhtml&lt;/namespace&gt;
+                 &lt;xpath&gt;/xhtml:html/xhtml:body&lt;/xpath&gt;
+             &lt;/luc:field&gt;
+             &lt;luc:field name="contents" type="UnStored" xpath="/"/&gt;
+             &lt;/luc:document&gt;</source>
+            </li>
+            <li> Create a batch file: <tt>C:\apache-lenya-1.2.2\tools\bin\Index-{pub}.bat</tt> With this:
+            <source>
+             SET LENYAPUB={pub}
+             SET CLASSPATH=.
+             SET ANT_HOME=C:\apache-lenya-1.2.2\tools
+             ant -f ../../build/lenya/webapp/lenya/bin/crawl_and_index.xml
+            -Dlucene.xconf=../../build/lenya/webapp/lenya/pubs/%LENYAPUB%/config/search/lucene-live.xconf
+            index</source>
+            </li>
+            
+            <li> To create a logfile (and avoid some ant errors), create a file: <tt>C:\apache-lenya-1.2.2\tools\bin\log4j.properties</tt> With this:
+            <source>
+             log4j.rootLogger=INFO, lucene
+             log4j.appender.lucene = org.apache.log4j.FileAppender
+             log4j.appender.lucene.File = lucene.log
+             log4j.appender.lucene.Append = false
+             log4j.appender.lucene.layout = org.apache.log4j.PatternLayout
+             log4j.appender.lucene.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p
+            %-30.30c{2} %x - %m %n</source>
+            </li>
+            
+            <li> Quit Lenya (to avoid file-locking issues). Run the batch file. Check the  log.The index created works, but the results are not formatted properly.</li>
+            <li> "sitemap.xml" may appear.</li>
+            <li> All links are wrong. They have an extra slash and "/index_xx.xml" must be changed to ".html".</li>
+            <li> The excerpt is not available and displays a Java error.</li>
+            <li>These are fixed in the next section.</li></ol>
+            
+            </section><section><title>Fix the XML results to be usable.</title>
+            <p>Copy <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\xslt\search\sort.xsl</tt> To: <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\lenya\xslt\search\sort.xsl</tt>. Copy <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\xslt\navigation\search.xsl</tt>
+            to <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\lenya\xslt\navigation\search.xsl</tt>
+            After the other params, add this line:</p>
+            <source>&lt;xsl:param name="chosenlanguage"/&gt;</source>
+            <p>Add the usecase and language fields to the form tag:</p>
+            <source>
+            &lt;form&gt;
+                &lt;input type="hidden" name="lenya.usecase" value="search"/&gt;
+                &lt;input type="hidden" name="language" value="{$chosenlanguage}"/&gt;
+                &lt;input class="searchfield" type="text" name="query" alt="Search field"/&gt;
+                &lt;input class="searchsubmit" type="submit" value="Search" name="find"/&gt;
+            &lt;/form&gt;</source>
+            <p><a href="search-and-results.xsp">Download</a> new file: <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\lenya\content\search\search-and-results.xsp</tt> Based on <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\content\search\search-and-results.xsp</tt></p>
+            <ul>
+            <li>Removed useless information. (I like dynamic lists better than anyone, but Search is a standard function with standard outputs, so why bother? I only left the &lt;fields&gt; tag to separate our output from lucene's.)</li>
+            <li>Added language filter.</li>
+            <li>Added protected section filter.</li>
+            <li>Hardcoded ProtectedUrls. The default is to require visitors be in an  "employee" Group to access "/live/employee". <strong>Configure this for your website.</strong></li>
+            <li>Uses Groups rather than Roles. (Roles are useless as long as "world" inherits "visit" for everything.)</li>
+            <li>Fixed counters and total. (Total-hits changed from property to element of results.)</li>
+           <li>Other bug fixes</li></ul>
+            
+            <p><a href="searchfixer.xsl">Download</a> new file: <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\lenya\xslt\search\searchfixer.xsl</tt> This file converts our poor output to something usable.</p>
+            <ul><li>Add languages to configuration</li>
+            <li>Move total-hits from element to property of results.</li>
+            <li>Choose "title" from "htmltitle" or Lucene's "title".</li>
+            <li>Choose "excerpt" from "htmlbody", Lenya's "description", or Lucene's "excerpt"</li>
+            <li>Transform URI from lucene's "uri" (/about/jobs/index_en.xml) to Lenya link (about/jobs_en.html).</li>
+            <li>The default is to use htmlbody for the excerpt. <strong>This file must be modified when using Custom Doctypes that do not have a /html/body.</strong></li>
+            </ul> 
+            <p><a href="usecase-search.xmap">Download</a> new file:
+            <tt>C:\apache-lenya-1.2.2\build\lenya\webapp\lenya\pubs\{pub}\usecase-search.xmap</tt></p>
+            
+            </section><section><title>Blocking default search.</title>
+           <p> It is important to block the default search when implementing ProtectedAreas to prevent visitors from typing the URL of the default search (or, if this publication was in production, using a bookmark to the old search) and seeing links to protected documents.</p>
+           <ul> 
+            <li> Create new file:  <tt>build\lenya\webapp\lenya\pubs\{pub}\lenya\lucene.xmap</tt></li>
+            <li>Add content:
+            <source>
+             &lt;?xml version="1.0" encoding="UTF-8"?&gt;
+             &lt;map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"&gt;
+             &lt;map:pipelines&gt;
+                 &lt;map:pipeline&gt;
+                     &lt;map:match pattern="*/search-*/lucene.xml"&gt;
+                         &lt;map:redirect-to uri="/{page-envelope:publication-id}/live/index.html?lenya.usecase=search"/&gt;
+                     &lt;/map:match&gt;
+                     &lt;map:match pattern="*/search-*/lucene*"&gt;
+                         &lt;map:redirect-to uri="/{page-envelope:publication-id}/live/index.html?lenya.usecase=search"/&gt;
+                     &lt;/map:match&gt;
+                 &lt;/map:pipeline&gt;
+             &lt;/map:pipelines&gt;
+             &lt;/map:sitemap&gt;</source></li></ul>
+</section>   </body>
+</document>
\ No newline at end of file

Modified: lenya/docu/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewcvs/lenya/docu/src/documentation/content/xdocs/site.xml?rev=170273&r1=170272&r2=170273&view=diff
==============================================================================
--- lenya/docu/src/documentation/content/xdocs/site.xml (original)
+++ lenya/docu/src/documentation/content/xdocs/site.xml Sun May 15 15:34:30 2005
@@ -111,6 +111,7 @@
                 <ldapauthentication href="ldap_authentication.html" label="LDAP Authentication"/>
                 <cmsmenus href="cms_menus.html" label="CMS Menus"/>
                 <cmsscreens href="cms_screens.html" label="CMS Screens"/>
+                <howtosearch href="search.html" label="Search Publications"/>
             </howtos>
             <components href="components/" label="Components">
                 <accesscontrol href="accesscontrol/" label="Access&#160;Control">



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org