[opencms-dev] Why does this search script only work in site = "/"
Joe Desbonnet
jdesbonnet at gmail.com
Thu Dec 15 03:05:11 CET 2005
I've been following some of the recent discussion on search indexes on
the list. But I still can not get OpenCms search to work properly in
my case.
Here is a short JSP script which should print out the number of
keyword hits in my index. It only returns results if run the explorer
while Site = "/". I get zero hits if I set Site to my website.
This must be some sort of permissions problem -- ie my site is not
priviliged to access it's own index (??).
Joe.
<%@ page buffer="none" import="org.opencms.main.*,
org.opencms.search.*, org.opencms.file.*, org.opencms.jsp.*,
java.util.*" %><%
CmsJspActionElement cms = new CmsJspActionElement(pageContext,
request, response);
CmsSearch search = new CmsSearch();
search.init (cms.getCmsObject());
search.setIndex("JHL");
search.setQuery("commerce");
String[] fields = {"contents","title"};
search.setField(fields);
List result=search.getSearchResult();
if (result == null) {
out.write ("got null result list");
return;
}
out.write ("got " + result.size() + " results");
%>
Here is my indexes element in opencms-search.xml:
<indexes>
<index>
<name>JHL</name>
<rebuild>auto</rebuild>
<project>Online</project>
<locale>en</locale>
<sources>
<source>jhlSource</source>
</sources>
</index>
</indexes>
Here is my sources element in opencms-search.xml:
<indexsources>
<indexsource>
<name>jhlSource</name>
<indexer
class="org.opencms.search.CmsVfsIndexer" />
<resources>
<resource>/sites/HardimanLibrary/</resource>
</resources>
<documenttypes-indexed>
<name>xmlpage</name>
<name>xmlcontent</name>
<name>page</name>
<name>text</name>
<name>pdf</name>
<name>rtf</name>
<name>html</name>
<name>image</name>
<name>generic</name>
</documenttypes-indexed>
</indexsource>
</indexsources>
More information about the opencms-dev
mailing list