View File | Revision Log | Show Annotations | Download File | View Changeset
Revision: 58772
Committed: Thu Mar 2 15:49:18 2017 UTC (3 years, 4 months ago) by jhoffman
Content type: text/xml
File size: 4123 byte(s)
Log Message:
Moved project from without history

File Contents

# Content
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Copyright 2010-2013 Hippo B.V. (
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 -->
17 <!DOCTYPE document PUBLIC "-//Apache Software Foundation//DTD XDOC 1.0//EN"
18 "">
19 <document>
20 <properties>
21 <title>Search term documents usage</title>
22 </properties>
23 <body>
24 <section name="Introduction">
25 <p>The search term documents component allows you to get search results for documents that match a keyword in a
26 specified file. This allows you to retrieve documents matching a term that isn't necessarily in the document.
27 This can be used to implement sponsored links or search suggestions among other things.
28 </p>
29 </section>
30 <section name='Using the component'>
31 <p>
32 One may add the component to one's site configuration. Make sure you pass the "searchExt-searchTermParam"
33 parameter and set the value to the corresponding search input name. This tells the search extensions manager
34 what term to look up.
35 </p>
36 <p>
37 <img src="images/cms_console_component.jpg" alt="CMS console component"/>
38 </p>
39 <p>In the JSP file one may display the matching search term results by reading the "searchExtTermDocuments" list,
40 as in the following snippet from the demo project:
41 </p>
42 <source><![CDATA[<c:if test="${not empty searchExtTermDocuments and (fn:length(searchExtTermDocuments) > 0)}">
43 Found the following documents matching the term in the keyword list:<br/>
44 <c:forEach var="item" items="${searchExtTermDocuments}">
45 ${}
46 </c:forEach>
47 </c:if>]]></source>
48 </section>
49 <section name="Document Term Lists Location">
50 <p>
51 One can configure the document term list location in the
52 site/src/main/resources/META-INF/client-assembly/base.xml. This must point to a folder. The SeachExtManger will
53 look in all document term lists in this folder to find documents matching terms therein.
54 </p>
55 <source><![CDATA[<bean id="org.onehippo.forge.searchext.documents.api.SearchExtManager" class="org.onehippo.forge.documents.searchext.impl.SearchExtManagerImpl">
56 <property name="documentTermListsLocation" value="/keywords"/>
57 </bean>]]></source>
58 <p>Note: Before 2.01.00, the package name did not include "documents".</p>
59 </section>
60 <section name="Implementing your own component">
61 <p>Instead of using the search term documents component, one may implement his own version. The component must get
62 the instance of the SearchExtManager from a ComponentManager. One may then call the SearchExtManager's
63 getDocumentsByTerm method, passing the term to look up and the site content base bean.
64 </p>
65 <source><![CDATA[public void doBeforeRender(HstRequest request, HstResponse response) throws HstComponentException {
66 String searchTerm = "lookforme";
67 ComponentManager componentManager = (ComponentManager) this.getDefaultClientComponentManager();
68 SearchExtManager searchExtManager = componentManager.getComponent(SearchExtManager.class.getName());
69 List<HippoBean> docs = searchExtManager.getDocumentsByTerm(searchTerm, this.getSiteContentBaseBean(request));
70 request.setAttribute("searchExtTermDocuments", docs);
71 }]]></source>
72 <p>
73 One may also use the SearchExtManager instance to get the document search term lists location by calling
74 getDocumentTermListsLocation() and to manually invalidate the cached search terms by calling invalidate().
75 </p>
76 </section>
77 </body>
78 </document>


Name Value
svn:eol-style native
svn:keywords Id