[opencms-dev] Problem with Exporting JSP that displays a news item and lucene search results. Please help.

Trevor Lee Trevor.Lee at 4Loop.com.au
Mon Oct 27 05:38:01 CET 2003


Hi,

I am using News2.1 and Lucene Simple Search.

Whilst offline i am able to open up individual news items and do simple
searches.

However when i publish news.jsp and simple_search.jsp news item can not be
retrieved nor does simple search return the same values as per the offline
version.

What happens in the case of the offline simple_search.jsp is the files gets
listed. However, when doing the same action on the online version i get the
"no results found".
Here is the snippet of code for simple_search.jsp which is based on the
sample code:
<%
	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 class=\"searchMatches\">" +
myBundle.getString("label.generic.domain.search.noResult") + "</h2>");
		}
		else
		{
			float score;
			Document doc;
			String tLastMod;
			if(j == 1)
				out.println("<h2 class=\"searchMatches\">" +
myBundle.getString("label.generic.domain.search.oneResult") + "</h2>");
			else
				out.println("<h2 class=\"searchMatches\">" +
myBundle.getString("label.generic.domain.serach.results") +
Integer.toString(j) + ".</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=\"searchresultheading\"><b>" + "<a href=\"" +
cms.link(doc.get("abs_path")) + "\" class=\"searchResult\">"
								+ doc.get("title") + "</a></b><br><i class=\"searchResult\">");
				//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.");
	}
%>

1. What i am trying to achieve is access both the news items and simple
search functionality that is working in the offline version from the online
version.
If any one can help that would be good.

2. I've noticed that when i publish a module and then go online and run the
file, it doesnt contain the latest changes.... Is there anything i can do?

3. When you publish a project/site, do the offline files get copied to the
opencms/export directory?

thanks in advance for your help.

Cheers
Trevor




More information about the opencms-dev mailing list