[opencms-dev] What's wrong with this search script?

Joe Desbonnet jdesbonnet at gmail.com
Thu Jan 19 03:10:26 CET 2006


Here is a small script that tries to retreive results form an OpenCms
Lucene index called "JHL". The index exists (I can see the files in
WEB-INF/index/JHL/*) and I know there are entries in there which will
match my test keyword "test".

However it always returns 0 results, *unless* I run this script while
Site set to "/", in which case it returns results, but that is of no
use.

So: what is missing/wrong in this script?

<%@ page buffer="none"
import="java.util.List"
import="org.opencms.search.CmsSearch"
import="org.opencms.jsp.CmsJspActionElement"
%><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%
CmsJspActionElement cms = new CmsJspActionElement (pageContext,
request, response);
CmsSearch search = new CmsSearch();
search.init(cms.getCmsObject());
search.setIndex("JHL");
search.setQuery("test");
List results = search.getSearchResult();
out.println ("found " + results.size() + " results");
%>



More information about the opencms-dev mailing list