[opencms-dev] Lucene always show untitled and null for description: Problem exist

Ritwik Datta dattaritwik at yahoo.com
Mon Jan 19 11:16:01 CET 2004


Dear Ivan,
Thanks again for quich reply. As per your suggesstion I have changed my simple-search.jsp file. But it gives compilation error.
I tell you what I did. I have instatiated cms obeject and then used your code
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
out.println (cms.readProperty(doc.get("abs_path"),"Title"); 
out.println (cms.readProperty(doc.get("abs_path"),"Description"); 
Better you just go through my JSP file I am attaching herewith. Please correct it and send me across. Thanks in advance.
Regards,
Ritwik
 
=================== JSP Code========================
<%@ page import="net.grcomputing.opencms.search.lucene.SearchHelper, org.apache.lucene.search.Hits,
    org.apache.lucene.document.*, com.opencms.flex.jsp.*, java.util.Date" %>
<%
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
// This class has a bunch of useful methods for searching.
SearchHelper search = new SearchHelper(cms);
// Get the GET/POST parameter named "q"
String query = request.getParameter("q");
if(query != null) {
    // This does a text search using the query provided. 
    // org.apache.lucene.hits are returned.
    Hits hits = search.doSimpleSearch(query);
    //out.println("Hits");
    int i, j = hits.length();
    if(j == 0) {
        out.println("<h2>Your search found no matches. Please try again.</h2>");
    } else {
        float score;
        Document doc;
        String tLastMod;
        if(j == 1)
            out.println("<h2 class=\"search-mathces\">Your search found 1 match.</h2>");
        else
            out.println("<h2 class=\"search-matches\">Your search found " + Integer.toString(j) + " matches.</h2>");
        // For each hit, get the Document and print out some information (including a link) about each item that
        // matches.
        for(i = 0; i<j; ++i) {
            score = hits.score(i);
            doc = hits.doc(i);
            String lms = doc.get("last_modified");
            if(lms != null && !"".equals(lms))
                tLastMod = DateField.stringToDate(lms).toString();
            else tLastMod = "unknown";
            
            //tLastMod = "unknown";
            out.println("<p class=\"search-hit\"><b class=\"search-hit-title\">" 
                + "<a href=\"" + cms.link(doc.get("abs_path")) + "\" class=\"search-hit-link\">"
                + doc.get("title") + "</a></b><br><i class=\"search-hit-score\">");
            //out.print(score); // Score is between 0.0 and 1.0
            out.println("</i> " + doc.get("description") + " <br><span class=\"smalltext\">(Last modified: " + tLastMod + ")</span></p>");
        }
    }
} else {
    out.println("No results found.");
}
%>
============================================================
 
 
 
 
Ivan Jelenic <ivan.jelenic at nbs.yu> wrote:
Hi,
 
Try with this:
 
    doctitle = cmsObject.readProperty(doc.get("url"),"Title"); //with big T
    doctitle = cmsObject.readProperty(doc.get("url"),"Description"); //with big D
 
    doc.get("url") is a path in VFS to your file.
 
Hope it will work.
 
Best regards,
Ivan.
----- Original Message ----- 
From: Ritwik Datta 
To: opencms-dev at opencms.org 
Sent: Monday, January 19, 2004 10:08 AM
Subject: [opencms-dev] Lucene always show untitled and null for description: Pls help


Dear All,

I am using OpenCMS on Oracle9i and Tomcat 4.1. I have imported lucene
module net.grcomputing.opencms.search.lucene_1.3.zip .but I have some problems. My files have titles and decription. But  lucene always show untitled and null for description. Can you tell me the work around. Now Ihave another question, to index my doc, pdf files, is there any additional patches released yet? This is very rgent requirement. So if you have solutions please send it accross
Thanks in advance,
regards,
Ritwik



---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes


---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040119/185fb628/attachment.htm>


More information about the opencms-dev mailing list