[opencms-dev] Is the search module usable at all?
Volker Goetz
goetz at sectionone.de
Tue Apr 4 11:51:24 CEST 2006
Hi Robert,
Am Dienstag, 4. April 2006 11:02 schrieb Robert Petermeier:
> Hi Volker,
> go ahead and post your complete config. I also only recently managed to
> get the search working in a multi-site setup. It's easy to shoot
> yourself in the foot. It might well be just some minor glitch. Maybe we
> can spot it.
Here we go :-) - I will omit everything that's left over from OpenCms'
default configuration.
--------------- START opencms-search.xml ---------------
<opencms>
<search>
<indexes>
<index>
<name>SectionOne Online</name>
<rebuild>auto</rebuild>
<project>Online</project>
<locale>de</locale>
<sources>
<source>sourceSectionOne</source>
</sources>
</index>
<index>
<name>SectionOne WORK</name>
<rebuild>auto</rebuild>
<project>SectionOne</project>
<locale>de</locale>
<sources>
<source>sourceSectionOne</source>
</sources>
</index>
<indexsource>
<name>sourceSectionOne</name>
<indexer class="org.opencms.search.CmsVfsIndexer"/>
<resources>
<resource>/sites/SectionOne/</resource>
</resources>
<documenttypes-indexed>
<name>generic</name>
<name>html</name>
<name>image</name>
<name>jsp</name>
<name>msexcel</name>
<name>mspowerpoint</name>
<name>msword</name>
<name>pdf</name>
<name>rtf</name>
<name>text</name>
<name>xmlcontent</name>
<name>xmlpage</name>
</documenttypes-indexed>
</indexsource>
</search>
</opencms>
--------------- END opencms-search.xml ---------------
--------------- START search.html ---------------
<%@ page session="false" buffer="none"
import="java.util.*,org.opencms.main.*,org.opencms.search.*,org.opencms.frontend.templateone.*,org.opencms.util.*,org.opencms.jsp.*" %>
<%
// initialise the template bean
CmsTemplateSearch cms = new CmsTemplateSearch(pageContext, request,
response);
// include the template head
cms.includeWithPageUri("head");
%>
<jsp:useBean id="search" scope="request"
class="org.opencms.search.CmsSearch">
<jsp:setProperty name="search" property="*"/>
<%
search.init(cms.getCmsObject());
search.setMatchesPerPage(10);
search.setQueryLength(3);
search.setDisplayPages(11);
%>
</jsp:useBean>
<div class="element">
<h2><%= cms.buildSearchHeadline() %></h2>
<p style="vertical-align: middle;">
<form style="margin: 0;"
name="searchform"
method="post"
action="<%= cms.link("/search.html") %>"
onsubmit="return parseSearchQuery(document.forms['searchform'], '<%=
cms.key("search.error.wordlength") %>');">
<input type="hidden" name="action" value="search" />
<input type="hidden" name="query" value="" />
<input type="hidden" name="index" value="<%=
cms.getSearchIndexName() %>" />
<input type="hidden" name="searchPage" value="1" />
<input type="hidden" name="<%= CmsTemplateBean.PARAM_URI %>" value="<%=
cms.getRequestContext().getUri() %>" />
<input type="hidden" name="__locale" value="<%=
cms.getRequestContext().getLocale() %>" />
<input type="text" name="query2" class="search" style="width: 350px"
value="<%= CmsStringUtil.escapeHtml(search.getQuery()) %>" /></span>
<input type="submit" value="<%= cms.key("link.search") %>"
class="formbutton" /></span><br />
<%
if (cms.isSearchAllDisplayed()) {
%><br />
<input type="checkbox" name="<%= CmsTemplateSearch.PARAM_SEARCHALL %>"
value="true"<%= cms.getSearchAllChecked() %>>
<%= cms.key("search.text.all") %>
<%
}
%><br />
</form>
</p>
<%
CmsSearchManager searchManager = OpenCms.getSearchManager();
search.setQuery( "Glossar" );
for( Iterator i = searchManager.getIndexNames().iterator(); i.hasNext(); )
{
String indexName = (String)i.next();
out.println( "<hr><br>Try index '" + indexName + "'<br><br>" );
search.setIndex( indexName );
// get the search results for the page
List result = cms.getSearchResults(search);
out.print(cms.buildSearchErrorMessages(search, result));
if (result != null && result.size() > 0) {
// show the result list
out.print(cms.buildSearchResultList(result));
// show the links to other result pages
out.print(cms.buildSearchLinks(search));
}
}
// include the template head
cms.includeWithPageUri("foot");
%>
--------------- END search.html ---------------
--
Best regards
Volker Götz
---------------------------------------------------------------
section(one Mail goetz at sectionone.de
Dipl.-Inform. Univ. Web http://www.sectionone.de/
Volker Götz Tel. +49 30 / 40 00 67 9-0
Rosa-Luxemburg-Straße 15 Fax +49 30 / 40 00 67 9-15
D-10178 Berlin PGP 4FEB1C34 @ wwwkeys.de.pgp.net
---------------------------------------------------------------
More information about the opencms-dev
mailing list