ShowTable of Contents
Introduction
Integrating WebSphere Portal search with WCM content is a powerful way to allow end users to navigate the WCM content.
There is already documentation on how to integrate WP search and WCM content, follow to the existing whitepaper:
http://www.ibm.com/developerworks/lotus/library/wcm-search/
Since the above documentation already discusses basic search integration topics, this will focus on more advanced topics such as:
- What WCM metadata is available for searching against?
- How to search WCM content using this metadata
- How to add additional custom search metadata
What WCM metadata is available for searching against?
When the WCM search seed servlet provides the XML to the WP Search crawler, the following metadata is associated:
Name – the name field of the content
Title – the title field of the object
Descr – the description field
Authors – the authors of the object, in the full distinguished name form
Keywords – the keywords of the object
Lastmodifieddate – the last modified date of the document.
AuthoringTemplate – the Title of the authoring template for the object, assuming content
Category – the Titles of the categories associated with the content
Modifier – the last modifier, in full distinguished name format
Owners – the owners of the document, in full distinguished name format
ExpirationDate – expiration date of the document,
EffectiveDate – effective date of the document
CONTENT_UUID – the UUID of the document. UUID is the unique identifier within JCR/WCM
CONTENT_PATH – the path to the content within WCM
How to search WCM content using this metadata
There are different ways to search against WCM content using this metadata. One way is to use the WCM defined search attributes in an HTML form, and submit to a WCM Search Component. In the WCM infocenter, and in the whitepaper, it's already documented how to do simple searching against this metadata. Basically, you create HTML form, and include the search_query to include the query string, and then you can add any of the above attributes by adding form elements with those names:
Search parameters
The following parameters can be used in a search query in this format:
<input name="search_parameter" />
|
|
Used to search the content of any elements stored in a content item.
|
|
|
Used to search the authoring template, if available, that was used to create the content item.
|
|
|
Used to search the name or names of the authors for the content item, if any are defined.
|
|
|
Used to search the categories of the content item if any are defined.
|
|
|
Used to search the description of the content item.
|
|
|
Used to search the effective date of the content item.
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
|
|
|
Used to search the expiration date of the content item.
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
|
|
|
Used to search the keywords of the content item if any are defined.
|
|
|
Used to search the last modified date of the content item.
Note: Search by date only works with the format MMM DD YYYY. For example, Sep 20 2006. To change the format, you will need to edit the SearchService.DateFormatString parameter in the SearchService.properties file.
|
|
|
Used to search the name of the last person to modify the content item.
|
|
|
Used to search the name of the content item.
|
|
|
Used to search the name or names of the owners of the content item, if any are defined.
|
|
|
Used to search the title of the content item.
|
So as a simple example. Lets say I want to search for content that includes the term “IBM”, AND is tagged with a category that has a title of “IBM”.
I would have a form like the following:
<form
action='<PathCmpnt type="servlet"/>/path/to/content/with/searchcmpnt method="post">
<table>
<tr><td>
Search Query:
<input type="text" name="search_query"/><br>
Search Category:
<input type="text" name="search_categories"/><br>
</td></tr>
<tr><td align="right">
<input type="submit" value="Search"/>
</td></tr>
</table>
</form>
And in the form, you would enter for search_query IBM, and for search_categories IBM.
When you submit the form, WCM takes the information from the request, and translates to a search query to issue against the SIAPI (Search and Indexing API).
The query it would issue is
IBM ^category:IBM
This is important, if you notice the ^. That tells the underlying WP search that we want content that contains IBM AND is categorized with IBM. Out of the box, this is the way that WCM treats additional attributes that are passed through the HTML form.
That's the way that the search_ attributes all work. They are great for building simple search queries, and presenting a simple search form to the end user.
However, what if you want to build more complex search strings? If you want to build more complicated search queries, you will have to do some URL manipulation, and pass as a whole string to the search_query parameter.
In order to do so, you will need to know what SIAPI attributes the WCM search_ tags are mapped to.
For example, search_categories maps to SIAPI being passed Category:
Use the following chart to build your queries:
Knowing this information, as well as how the SIAPI expects its queries to be structured, you can create powerful searches to pass to WCM Search Component.
Specific example
So now that we have the general idea, lets look at a specific example. For this example, I have the following:
1. A content object to hold the search form and results
2. Some content that's tagged with categories, and has specific searchable content contained.
Creating the necessary infrastructure
To create the underlying structure necessary for the search, I started out very simple. We will assume a basic understanding of WCM, and not get into the numerous specifics.
I took the following steps:
1. Created a search collection named CKDemoCollection.
2. Create an Authoring template, include a Component Reference named “CompRef”.
3. Create a presentation template, including the html:
<Element context=”current” type=”content” key=”CompRef”/>
4. Create Site named SiteDemoSearchSite. Mapped the Authoring template to the presentation template
5. Create Site Area named SiteDemoSearchSiteArea
6. Created Search Component. In the search component fields, used the following values:
Header:
<table>
<tr>
<td>Attribute</td><td>value</td><tr>
Results:
<tr><td>link</td><td>
<a href="/wps/myportal/searchResults?WCM_GLOBAL_CONTEXT=<AttributeResource attributeName="url" separator=","/>"><AttributeResource attributeName="name" separator=","/></a></td></tr>
Footer:
</table>
Separator: <tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
No Result Design: There are no results for your query. Please refine your search and try again.
Only one important thing to point out:
<a href="/wps/myportal/searchResults?WCM_GLOBAL_CONTEXT=<AttributeResource attributeName="url" separator=","/>"><AttributeResource attributeName="name" separator=","/></a>
What this does is the URL that's generated for the search result is prepended with /wps/myportal/searchResults?WCM_GLOBAL_CONTEXT=. This means that when the link is clicked, it will bring the user to a WP page with a friendly URL mapping of searchResults. On that page there will be a local rendering portlet deployed.
Finally, I populated the Search Component with CKDemoCollection as the search collection.
7. Created an HTML component to hold the search form. Included the following HTML:
<form action='' method="post"> <table> <tr><td> <input type="text" name="search_query"/> </td></tr> <tr><td align="right"> <input type="submit" value="Search"/> </td></tr> </table> </form> Results:<br> <Component name="search - demosearchcomponent"/><br>
All this does is place the search form and the results on the same component. The action='' is used to submit the form to itself.
8. Created piece of content, using the authoring template created above. Populated CompRef with the html search form.
9. Created 2 WP pages. Created friendly URL mapping for searchResults, pointed at one of the new pages. Deployed Local Rendering Portlet to both pages, configured the local rendering portlet on searchResults page to a dummy piece of content, set it up to receive links from this and other portlets. Configured the portlet on the other page to a piece of default content, and the ability to receive links from this and other portlets.
So the general idea is that when you issue a search, the links for the results will show in the same form as the search. However, clicking a link will break you out to a different page, so that you don't lose the search context.

Advanced Searching for Content
We won't detail how all the test content was created. The important pieces for the sample:
- Authoring Template for all content was named “AT – DEMO_AT”
- Used the following set of WCM categories to tag the content:
- Entered the following into every piece of content in a rich text field: TestSearchTerm
- Have the following 5 Content objects:
The idea of using the same authoring template, and search term, but different Categories, is that we can show some advanced search queries.
The query syntax that SIAPI uses follows the syntax from the Omnifind product documentation. This document uses the information here:
http://publib.boulder.ibm.com/infocenter/wsiihelp/v8r3/topic/com.ibm.websphere.ii.foundation.appdev.esearch.doc/developing/iiyspqysyntx.htm
Query Examples
First, we'll start with a very basic query. This returns all the content that contains the term TestSearchTerm. Enter TestSearchTerm in the search box, all of the content will be returned:

Next, we'll search for all content that contains the TestSearchTerm, AND is categorized with the category Group1. Enter into the search box TestSearchTerm +Category:Group1:

Next, lets search for all content that contains the TestSearchTerm AND is categorized with either Group1 or Group2. Enter into the search box TestSearchTerm ^(Category:Group1 | Category:Group2)

Finally, lets get all content that contains TestSearchTerm, but is NOT categorized with Group1 or Group2. Enter into the search box TestSearchTerm -Category:Group1 -Category:Group2

How to add additional custom search metadata
Now that you can build advanced queries, you may wish to add your own custom searchable attributes. For example, lets say you want to tag content with an additional keyword type value that you do not wish to use as a keyword for the WCM content.
Following the instructions in the infocenter:
http://publib.boulder.ibm.com/infocenter/wpdoc/v6r1m0/topic/com.ibm.wp.ent.doc_v6101/wcm/wcm_config_search.html
It notes that you will basically have to update a properties file, and restart the sever. For this example, I have set the following:
SearchService.MetaFields=metaText,meta
So now that WCM is making this a searchable field, that field needs to be added to the content. For the purposes of this documentation, I just added the component directly to a piece of content:
1. Opened content open for edit
2. Clicked on the Manage Elements button to add the element
3. Added text component named “metaField”
4. After adding, populated it with “metaTextSearch”
5. Save and close the content.
Once the content has the component added, the search crawler needs to rerun so that the value gets placed into the search crawler information for the content.rr
After the crawl, you can now issue search like meta:metaTextSearch, and the content will be returned.
So, for this:
SearchService.MetaFields=metaText,meta
meta is the key, which will be the lookup
metaText is the attribute name that will be used to populate the value within the search collection.