Configuration
(Difference between revisions)
(added sample search code) |
m (formatting) |
||
Line 5: | Line 5: | ||
− | CmsJspActionElement cmsJae = new CmsJspActionElement(pageContext, request, response); | + | CmsJspActionElement cmsJae = new CmsJspActionElement(pageContext, request, response); |
− | CmsSearch search = new CmsSearch(); | + | CmsSearch search = new CmsSearch(); |
− | search.setIndex("online"); | + | search.setIndex("online"); |
− | search.setQuery(queryString); | + | search.setQuery(queryString); |
− | search.init(cmsJae.getCmsObject()); | + | search.init(cmsJae.getCmsObject()); |
− | List searchResults = search.getSearchResult(); | + | List searchResults = search.getSearchResult(); |
− | Iterator iterator = searchResults.iterator(); | + | Iterator iterator = searchResults.iterator(); |
− | while (iterator.hasNext()) { | + | while (iterator.hasNext()) { |
− | + | CmsSearchResult r = (CmsSearchResult)iterator.next(); | |
− | + | //do stuff... | |
− | } | + | } |
Revision as of 17:27, 13 June 2007
OpenCms comes with a built in search index for the online and offline projects. Additional search indices can be created but have to be done through editing the XML config files.
You would use the search index in a JSP something like this:
CmsJspActionElement cmsJae = new CmsJspActionElement(pageContext, request, response); CmsSearch search = new CmsSearch();
search.setIndex("online"); search.setQuery(queryString); search.init(cmsJae.getCmsObject()); List searchResults = search.getSearchResult();
Iterator iterator = searchResults.iterator(); while (iterator.hasNext()) { CmsSearchResult r = (CmsSearchResult)iterator.next(); //do stuff... }