45 Integrating the Search Service

This chapter explains how to integrate the Search service in a WebCenter Portal: Framework application at design time.

For more information about managing and including search, see:

This chapter includes the following sections:

45.1 Introduction to Search

WebCenter Portal's search provides a unified, extensible framework that enables the discovery of information through an intuitive user interface. It honors application security settings by returning only the results a user is authorized to view. Users can save their searches for reuse, including searches with complex search refinement conditions.

WebCenter Portal provides two ways of searching your application:

  • Oracle Secure Enterprise Search (SES) adapter

  • Oracle WebCenter Portal live search adapters

In addition, the Documents service provides its own search engine for file searches. This saves time and increases the relevancy of results by narrowing the scope of a search to files.

See Also:

Section 14.4, "Using Portal Navigation to Create a Sitemap" for information about integrating an external search engine in your application

45.1.1 Understanding the Search Service

With Framework applications, Oracle Secure Enterprise Search (SES) is set as the default and preferred search platform. Oracle SES provides unified ranking results for the following resources:

  • Documents, including wikis and blogs

  • Announcements and Discussions

  • Spaces, lists, page content, and people resources in WebCenter Portal: Spaces

Note:

WebCenter Portal: Spaces applications include the Oracle SES crawler that indexes spaces, lists, pages, and people resources in Spaces. This crawler is not supported in Framework applications.

Oracle SES search is beneficial for the following reasons:

  • Oracle SES search provides unified ranking results, with the most relevant items appearing first.

  • Oracle SES search allows search of repositories outside of WebCenter Portal. Oracle SES results appear in the same result set as WebCenter Portal's search results.

  • Oracle SES search supports the Search service REST APIs and data control for customizing your search interface.

45.1.1.1 Understanding Search with the Oracle SES Adapter

Supported Oracle SES versions include 10.1.8.4.x and later. Oracle strongly recommends using Oracle SES release 11.1.2.2. Search with Oracle SES requires additional configuration in Oracle SES Administration, Oracle WebCenter Content: Content Server, and Oracle WebCenter Portal's Discussion Server.

45.1.1.2 Understanding Search with WebCenter Portal's Search Adapters

Although Oracle SES is the preferred search platform for best performance, you can manually override search with Oracle SES and have Framework applications search using WebCenter Portal's original search adapters. WebCenter Portal's search adapters span all enabled and searchable services, such as documents, tags, people, and pages.

45.1.1.3 Click Actions on Search Results

If no Resource Action Handling is specified in the Framework application, then the default action when a search result is clicked is to render the search result in a new browser window. Also, results from services that provide resource viewers, such as Documents, Discussions or Announcements, open in their resource viewers. For more information about resource viewers and the Resource Action Handling framework, see Section 7.3, "Extending Your Framework Application with Custom Components."

45.1.2 What Happens at Runtime

At run time, users can perform global (application-wide) searches from the Search task flow or from the Search toolbar and refine and save searches.

For more information about WebCenter Portal's search at runtime, see Oracle Fusion Middleware User's Guide for Oracle WebCenter Portal: Spaces.

45.2 Basic Configuration for the Search Service

This section provides the steps for adding the Search service to your application. It includes the following subsections:

45.2.1 Configuration Roadmap - Oracle SES

Use the roadmap in this section as a guide through the configuration process.

Note:

If you override search with Oracle SES to use the original WebCenter Portal live search adapters, then no Oracle SES configuration is required. Skip ahead to section Section 45.2.3, "Adding the Search Service at Design Time."

Figure 45-1 and Table 45-1 provide an overview of the prerequisites and tasks required to get Oracle SES working in Framework applications.

Figure 45-1 Configuring Oracle SES for Framework Applications

Description of Figure 45-1 follows Install WebCenter Portal: Framework and Oracle SES Configure Oracle SES with an identity management system Set up a Document Service Manager in Oracle SES Create a Federation Trusted Entity Create two crawl sources: Documents Crawler and Discussions Crawler Create a source group for the crawl sources Configure a connection to Oracle SES in JDeveloper Add a Search service task flow to a page in JDeveloper Deploy using JDeveloper Deploy the application Deploy using WLST Deploy using WLS Admin Console (Optional) Secure the connection to Oracle SES with SSL Configure additional search parameters
Description of "Figure 45-1 Configuring Oracle SES for Framework Applications"

Table 45-1 Configuring Oracle SES for Framework Applications

Actor Task Sub-task

Administrator

1. Install WebCenter Portal and Oracle SES

 
 

2. Configure Oracle SES with an identity management system

 
 

3. Set up a Document Service Manager in Oracle SES

 
 

4. Create a Federation Trusted Entity using one of the following tools:

  • Oracle SES Admin Tool

  • WLST

 
 

5. Create two crawl sources: Documents Crawler and Discussions Crawler using one of the following tools:

  • Oracle SES Admin Tool

  • WLST

 
 

6. Create a source group for the crawl sources using one of the following tools:

  • Oracle SES Admin Tool

  • WLST

 

Developer

7. Integrate the Search service in your application

7.a Configure a connection to Oracle SES in JDeveloper

   

7.b Add a Search service task flow to a page in JDeveloper

Developer or Administrator

8. Deploy the application using one of the following tools:

 

Administrator

9. (Optional) Secure the connection to Oracle SES with SSL

 

Administrator

10. Configure additional search parameters using one of the following tools:

  • Fusion Middleware Control

  • WLST

  • WLS Admin Console

 

45.2.2 Setting up Connections for Oracle SES

To search with Oracle SES, you must add the Oracle SES connection in the application. For more information, see Section 45.3.4, "Configuring Search with the Oracle SES Adapter."

Note:

You can create a connection to Oracle SES to search repositories outside WebCenter Portal and override using Oracle SES as the default search crawler with Fusion Middleware Control or WLST. This allows users to search other Framework application resources, such as people.

  1. Add the search toolbar to a page, following Section 45.2.3, "Adding the Search Service at Design Time."

  2. Set up a connection to Oracle SES. In the Application Navigator, expand Application Resources. Right-click the Connections node, select New Connection, and then Oracle Secure Enterprise Search.

    Select to create the connection in either the Application Resources or IDE connections. A connection in Application Resources is available only for that application, while a connection in IDE connections is available for all applications you create. If you plan to use the connection in other applications, then select IDE connections to avoid the need to re-create it.

    Note:

    If you create the connection in IDE, then the connection must be added to the application later. For example, in the Resource Palette under IDE connections, right-click the connection and select Add to Application.

    Enter values for the fields in the dialog. For example:

    1. For Connection Name, enter a meaningful name, for example, SESconnection. This name cannot be changed after it is created. (To use a different connection name, create a new connection.)

    2. For SOAP URL, enter the URL for the Oracle SES Web Services endpoint, for example:

      http://host:port/search/query/OracleSearch
      
    3. Under Federation Trusted Entity, for Entity Name, enter the trusted entity defined for this application on the Oracle SES instance; for example, wcsearch.

      A trusted entity allows the application to authenticate itself to Oracle SES and assert its users when making queries on Oracle SES. This trusted entity can be any user that either exists on the identity management server behind Oracle SES or is created internally in Oracle SES. You can find (or create) the trusted entity on the Global Settings - Federation Trusted Entities page of Oracle SES.

    4. For Entity Password, enter the password of the Federation Trusted Entity user.

    5. Under Application Configuration, select the box for Set as default connection for the Search service.

      This ensures that your application uses that connection to access Oracle SES. The Search service uses only one Oracle SES connection.

      Note:

      After you create a connection as the default connection, you cannot edit it so that it is not the default. To use a different default connection, you must create a new connection and mark that as the default connection.

    6. For Source Group, enter the Oracle SES source group in which to search. If a value is not provided, then all crawl sources in the Oracle SES instance are searched.

      Note:

      Source groups present a good way to segment your searchable data on Oracle SES. Given an Oracle SES instance that keeps a search index on all corporate data, you can use source groups to make only a portion of your corporate data available to WebCenter Portal's search. For more information on creating source groups, see Oracle SES Administrator's Guide.

    7. Under Testing, for User name, enter the name of a user present in both the Oracle Identity Management server configured for your application and the Oracle Identity Management server configured for Oracle SES.

      You should see something similar to Figure 45-2.

    8. Figure 45-2 Create Oracle SES Connection Dialog

      Description of Figure 45-2 follows
      Description of "Figure 45-2 Create Oracle SES Connection Dialog"

    Click Test Connection and check the status.

    If the connection is successful, then click OK.

After you have included the Oracle SES connection in your application, you should see it in your Application Resources panel, as shown in Figure 45-3.

Figure 45-3 Oracle SES Connection in Application Resources

Description of Figure 45-3 follows
Description of "Figure 45-3 Oracle SES Connection in Application Resources"

The Oracle SES connection is now included in the connections.xml file and is the default connection in the adf-config.xml file, as shown in Example 45-1.

Example 45-1 Oracle SES Connection in adf-config.xml

<ses-properties>
  <connection>SESconnection</connection>
  <data-group>MySources</data-group>
</ses-properties>

Note:

After a Framework application has been deployed to an Oracle WebLogic managed server, you can configure it using WLST or Fusion Middleware Control. For more information, see Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter Portal.

45.2.3 Adding the Search Service at Design Time

This section describes the Search service task flows and explains how to integrate the Search service into your application. It includes the following subsections:

45.2.3.1 Search Service Task Flows

Table 45-2 lists the Search service task flows.

Table 45-2 Search Service Task Flows

Task Flow Definition

Search

This task flow provides a rich search experience with features for refining and saving search results.

Search - Saved Searches

This task flow enables you to create a simple launch pad for running saved searches within the application.

Search Preferences

This task flow enables users to select which WebCenter Portal services to search.

Search Toolbar

This task flow enables users to enter simple search criteria and run the search from the application. Search results are rendered as links.


45.2.3.2 How to Add the Search Service to Your Page

The Search Toolbar task flow offers the easiest way to add the Search service to your application. To add the Search Toolbar task flow to your Framework application:

  1. Follow the steps described in Chapter 3, "Preparing Your Development Environment" to create a customizable page in your application.

    Note:

    ADF security is configured by default if you created your application using WebCenter Portal's Framework application template. For information about configuring ADF security, see Section 69.3, "Configuring ADF Security."

  2. Open the page on which to add the Search service.

  3. In the Resource Palette, expand My Catalogs, WebCenter Portal - Services Catalog, and Task Flows.

  4. Drag and drop the Search Toolbar task flow onto the page.

  5. When prompted, select Region as the way to create the task flow.

    If a prompt to confirm the ADF library appears, click Add Library.

  6. Run your page with the search toolbar on it.

    In the Application Navigator, right-click this application and select Run. It may take a few moments for the operation to complete.

    Enter the user name and credentials that you created when you defined security.

    Note:

    To return results, the Search service requires that other WebCenter Portal services are included in the application.

45.2.3.3 How to Modify the Search Service Task Flow Parameters

With the Search service task flow parameters, you can customize the appearance and behavior of a task flow instance. For example, you can restrict search results to include only specific services, document types, and spaces, or you can change the size of the search box.

See Also:

"How to Set Parameters to Narrow Search" in Oracle Fusion Middleware User's Guide for Oracle WebCenter Portal: Spaces for detailed information about customizing the Search service with task flow parameters

To see and adjust task flow binding parameter values after you have placed a task flow on a page:

  1. Navigate to the Edit Task Flow Binding dialog by clicking the Bindings tab at the bottom of the page containing the task flow (next to the Source tab).

  2. Under Executables, you'll see the task flow you added. Figure 45-4 shows an example of a Search task flow in the Executables section.

    Figure 45-4 Page Data Binding Definition

    Description of Figure 45-4 follows
    Description of "Figure 45-4 Page Data Binding Definition"

  3. Select the task flow, and next to the Executables heading, click the Edit selected element (pencil) icon.

  4. In the Edit Task Flow Binding dialog Figure 45-5, revise the binding parameter value by double-clicking the field and either changing the existing value or adding a new one.

    Figure 45-5 Edit Task Flow Binding Dialog for Search Task Flow

    Description of Figure 45-5 follows
    Description of "Figure 45-5 Edit Task Flow Binding Dialog for Search Task Flow"

  5. When you are finished, click OK.

  6. Save and run your page to see the results.

Table 45-3 describes the properties that are unique to the Search service task flows.

Table 45-3 Search Service Task Flow Parameters

Property Description Task Flow

customAttributes

List of custom attributes to show when displaying search results.

To include one or more custom attributes in the search results, set this to a list of custom attribute names, separated by commas. An optional label prefix may be provided with the custom attribute name to display instead of its associated custom attribute name. Use the format: label:name.

Search

Search Toolbar

hideRefiners

List of refiners to hide when displaying search results.

To hide one or more refiners, set this to a list of refiner names, separated by commas (choose from creator, date, space, content, and tags).

Search

Search Toolbar

keywordsInputRendered

Show or hide the input box.

Set to true (default) to show the input box, or set to false to hide it.

Search

mimeType

List of MIME types to limit the search.

To limit the search to certain document types, set this to the list of MIME types of the documents (such as PDF, PPT, DOC), separated by commas.

This also can be set to the Documents service with oracle.webcenter.doclib.

Note: To limit search to Microsoft Word documents and WebCenter Portal pages, set this parameter to application/msword, and set the serviceIds parameter to oracle.webcenter.doclib,oracle.webcenter.page.

See Also: "Searching Specific Document Types" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter Portal

Search

Search Toolbar

searchScope

List of unique IDs to limit the search scope. To limit the search to a list of spaces, set this to the list of GUIDs of the spaces, separated by commas.

For example: #{spaceContext.currentSpaceGUID} or s8bba98ff_4cbb_40b8_beee_296c916a23ed

Search

Search Toolbar

resourceScope

Unique ID to limit the search scope. To limit the search to a particular space, set this to the GUID of the space.

For example: #{spaceContext.currentSpaceGUID} or s8bba98ff_4cbb_40b8_beee_296c916a23ed

Note: This parameter has been deprecated. It is included for backward-compatibility only.

Search

searchBoxSize

Value to limit the size of the search box.

The default value is 42. Enter a lower number (for example, 30) to shorten the length of the search box. This also changes the size of the search box in the Search task flow.

Search Toolbar

serviceIds

List of IDs of services or executors to include when displaying search results.

To display only people profiles and documents in the Content Server, set this parameter to oracle.webcenter.peopleconnections.profile, oracle.webcenter.doclib. If nothing is specified, then all services are searched.

For a list of service IDs, see Table G-7, "Service IDs".

Search

Search Toolbar

resourceId

Either search keywords or the saved search GUID.

Note: This parameter is for internal use only. Do not change this value unless you want coded search main views. If you do change this value, then you must also specify resourceType.

Search

resourceType

Marker specifying whether the resourceId parameter searches keywords or saved search GUID.

Note: This value is set automatically and is for internal use only. Do not change it unless you want coded search main views.

Search

scope

List of unique objects to limit the search scope.

Note: This parameter has been deprecated. Use the searchScope parameter instead. (If a value is set for this parameter, then any value in searchScope is ignored.)

Search Toolbar


Note:

The All Saved Searches and the Search Preferences task flows do not have any unique properties.

45.2.4 Setting Security for the Search Service

The Oracle SES adapter must be configured with an identity management system to validate and authenticate users. This is necessary for searches to return only results that the user is allowed to view based on access privileges. Because WebCenter Portal uses identity propagation when communicating with Oracle SES, WebCenter Portal's user base must match that in Oracle SES. One way this can happen is by configuring WebCenter Portal and Oracle SES to the same identity management system. For detailed information, see the section "Oracle SES - Configuration" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter Portal.

WebCenter Portal's original search adapters rely on individual services to ensure that the user performing the search can view results. Search results are returned based on user privileges. When unauthenticated, queries return only public content. Only authenticated users of an ADF-secured Framework application can save searches.

ADF security is configured by default if you created your application using WebCenter Portal's Framework application template. For information about configuring ADF security, see Section 69.3, "Configuring ADF Security."

45.3 Advanced Information for the Search Service

This section describes optional features available with this service. It includes the following subsections:

Note:

The Search service REST APIs and data controls are available only for search using Oracle SES. They are not supported with search using WebCenter Portal's original search adapters.

45.3.1 Adding the Search Task Flow

To add the Search task flow to your application, follow the instructions provided for the Search Toolbar task flow in Section 45.2.3, "Adding the Search Service at Design Time," but instead, drag and drop the Search task flow onto the page.

To run the page with the Search view:

  1. In the Application Navigator, right-click the page and select Run. As long as the application has been ADF-secured, you should see a login page. It may take a few moments for the operation to complete.

  2. If you configured ADF security, then enter the user name and password that you provided and click Submit.

  3. Enter some search criteria in the field and click the Search icon. You may get few, if any, results if the application is not populated with much besides the Search service itself.

45.3.2 Adding the Search - Saved Searches Task Flow

You can add the Search - Saved Searches task flow to provide a simple launch pad for running saved searches within the application. To add this task flow to your Framework application, follow the instructions provided for the Search Toolbar task flow in Section 45.2.3, "Adding the Search Service at Design Time," but instead, drag and drop the Search - Saved Searches task flow onto the page.

The task flow renders links that, when clicked, run a saved search.

45.3.3 Adding the Search Preferences Task Flow

The Search Preferences task flow enables users to control which WebCenter Portal services are searched. By default, all enabled services are selected to be searched. Users can disable any service from which they do not want to see search results. Users also can select the order of services in their search results. For example, they may find that search results from the Documents service prove more useful that search results from other services.

To add the Search Preferences task flow to your application, follow the instructions provided for the Search Toolbar task flow in Section 45.2.3, "Adding the Search Service at Design Time," but instead, drag and drop the Search Preferences task flow onto the page.

45.3.4 Configuring Search with the Oracle SES Adapter

WebCenter Portal: Framework applications automatically set Oracle Secure Enterprise Search (SES) as the default search adapter, but additional configuration is required in Oracle SES, Oracle WebCenter Content: Content Server, and Oracle WebCenter Portal's Discussion Server. See the section "Managing the Search Service" in Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter Portal for detailed information about the steps to set up search with the Oracle SES adapter.

After you have completed all configuration steps, validate the inclusion of Oracle SES results in WebCenter Portal's search.

  1. In the Application Navigator, right-click the page you created with the Search Toolbar, and click Run.

    As long as the application has been ADF-secured, you should see a login page. It may take a few moments for the operation to complete.

  2. Enter the user name and credentials that you created when you defined security.

  3. Click Submit.

    When the page loads, you should see your search toolbar.

    Figure 45-6 shows a sample results page for the search term webcenter, before Oracle SES has crawled anything.

    Figure 45-6 Search Results

    Description of Figure 45-6 follows
    Description of "Figure 45-6 Search Results"

    Figure 45-7 shows a sample results page after Oracle SES has been configured and crawled.

    Figure 45-7 Global Search Results

    search results

See Also:

Oracle SES documentation provided on the Oracle Fusion Middleware documentation library (in WebCenter Portal's product area)

45.3.5 Configuring Search with WebCenter Portal's Search Adapters

You can manually override search with Oracle SES and have Framework applications search using WebCenter Portal's original search adapters. WebCenter Portal's search adapters span all enabled and searchable services, such as documents, tags, people, and pages.

To enable search with WebCenter Portal's search adapters, edit the adf-config.xml file either to change all enable attributes in crawl-properties to false (Example 45-2) or to comment out the crawl-properties entirely (Example 45-3).

Example 45-2 Crawl Properties in adf-config.xml Set to False

  <searchC:adf-search-config
xmlns="http://xmlns.oracle.com/webcenter/search/config">
    <display-properties>
      <common numSavedSearches="5"/>
      <region-specific>
        <usage id="simpleSearchResultUIMetadata" numServiceRows="5"/>
        <usage id="searchResultUIMetadata" numServiceRows="5"/>
        <usage id="localToolbarRegion" numServiceRows="5"/>
      </region-specific>
    </display-properties>
    <execution-properties timeoutMs="7000" prepareTimeoutMs="3000"/>
    <crawl-properties fullCrawlInterval="P5D" enableWcServicesCrawl="false"
                      enableWcDiscussionsCrawl="false" enableWcUcmCrawl="false"/>
    <ses-properties>
      <connection/>
      <data-group/>
    </ses-properties>
  </searchC:adf-search-config> 

Example 45-3 Crawl Properties in adf-config.xml Commented Out

  <searchC:adf-search-config
xmlns="http://xmlns.oracle.com/webcenter/search/config">
    <display-properties>
      <common numSavedSearches="5"/>
      <region-specific>
        <usage id="simpleSearchResultUIMetadata" numServiceRows="5"/>
        <usage id="searchResultUIMetadata" numServiceRows="5"/>
        <usage id="localToolbarRegion" numServiceRows="5"/>
      </region-specific>
    </display-properties>
    <execution-properties timeoutMs="7000" prepareTimeoutMs="3000"/>
    <!--
    <crawl-properties fullCrawlInterval="P5D" enableWcServicesCrawl="true"
                      enableWcDiscussionsCrawl="true" enableWcUcmCrawl="true"/>
    -->
    <ses-properties>
      <connection/>
      <data-group/>
    </ses-properties>
  </searchC:adf-search-config> 

45.3.6 Using the Search Service Java APIs

Custom components can implement Search service APIs to expose their content to WebCenter Portal's search.

For more information, see Oracle Fusion Middleware Java API Reference for Oracle WebCenter Portal.

45.3.7 Using the Search Service REST APIs

WebCenter Portal provides REST APIs to support the Search service. Use the Search service REST APIs to post, read, update, and delete searches. You can specify keywords and the scope of the search; for example, the iPhone could search for "smith" in all spaces, documents and wiki pages. The API also lets you build a customized search user interface on top of the Search service.

This section describes the REST APIs associated with the Search service. It includes the following subsections:

For an introduction to the REST APIs, see Chapter 54, "Using Oracle WebCenter Portal REST APIs."

45.3.7.1 Search Entry Point

Each REST service has a link element within the resource index that provides the entry point for that service. To find the entry point for the Search service, find the link element with a resourceType of:

urn:oracle:webcenter:search

The corresponding href or template element provides the URI entry point. The client sends HTTP requests to this entry point to work with the Search service.

For more information about the resource index, see Section 54.5.1, "The Resource Index."

For more information about resource types, see Section 54.5.2.1, "Resource Type."

45.3.7.2 Search Resource Type Taxonomy

When the client has identified the entry point, it then can navigate through the resource type taxonomy to perform the required operations. For more information about the individual resource types, see the appropriate section in Section 54.5.2.1, "Resource Type."

The taxonomy for the Search service is:

urn:oracle:webcenter:search
   urn:oracle:webcenter:search:results

Beyond the service entry points, URL templates allow clients to pass query parameters to customize their requests and control the form of returned data.

Collection resources in the search resources support pagination (startIndex and itemsPerPage). Other query parameters are not supported (that is, search and projection).

45.3.7.3 Security Considerations

Authentication is required before using Search REST API methods.

For general security considerations, see Section 54.8, "Security Considerations for WebCenter Portal REST APIs."

45.3.7.4 Search Resource Types

This section provides information about each resource type. It includes the following subsection:

45.3.7.4.1 urn:oracle:webcenter:search:results

Use this resource type to identify the URI to use to read (GET) a query containing keywords and attribute-specific criteria.

The request is represented by the URL and the response is a list of search results, each with metadata to help the end user choose an item to drill down, as well as cross links to the owning REST services, if available. If the owning REST service is unavailable, then an HREF link is provided.

The response XML can be paginated with standard URL parameters, and appropriate previous and next links provided along with a general template (with the query prepopulated) for the consuming application to do its own custom pagination.

Navigation Paths to results

This section shows how the client can navigate through the hypermedia to access this resource:

resourceindex
   search
resourceindex
   spaces
      spaces:resourceindex
         spaces:search

Supported Methods for results

The following methods are supported by this resource:

  • GET

    • request - body: none, Parameters: serviceId, q, scopeGuid, refiners, startIndex (pagination), itemsPerPage (pagination)

    • response - body: search results, and refiners (if refiners=true)

where:

  • serviceId={serviceId1}[,{serviceId2}...]

    Optional: This narrows the search to one or more WebCenter Portal services, such as oracle.webcenter.doclib or oracle.webcenter.page. For example, setting this to oracle.webcenter.doclib searches only documents. If omitted, this searches all services.

    See Also:

    Table G-7, "Service IDs" for a list of service IDs

  • q={queryString}

    Searches may be specified using the following format

    [[field1:[operand]][:]value1[;field2:operand:value2]]
    

    Where multiple clauses are joined by an implicit AND and are syntactically separated by the ";" semicolon. Square brackets [] denote optional values. Each clause can be one of the following types:

    • keywords - simple string with no ":" colon separator

    • attribute1:value1 - shortcut for a clause meaning attribute1 equals value1

    • attribute1:operand1:value1 - a clause capturing a Boolean condition between attribute1 and value1

    Search attributes include the following, but can be any attribute name:

    • title - Name or title of the item

    • description - Description of the item

    • creator - Creator or contributors of the item

    • date - Date on which the item was last modified

    • tags - Tag words that the item may have (applicable to pages)

    The attributes can be returned in search results, where data=field1[,field2]

    Legal operands:

    • equals - Strings and Numbers

    • contains - Strings

    • gt (greater than) - Numbers

    • gte (greater than or equals) - Numbers

    • lt (less than) - Numbers

    • lte (less than or equals) - Numbers

  • scopeGuid={...}

    Optional: The GUID associated with the scope.

  • refiners={true|false}

    Optional: Whether to fetch refiners. If omitted, the default value is false.

Example 45-4 Search REST Commands

http://examplehost:8888/rest/api/searchresults?q=document&serviceId=oracle.webcenter.doclib,oracle.webcenter.page&utoken={utoken}

http://examplehost:8888/rest/api/searchresults?q={keywords};dDocName:contains:handbook&data=dDocName,dOriginalName

For more information, see Section 54.5.2.5, "Templates."

Writable Elements for results

Table 45-4 lists the writable elements for this resource.

Table 45-4 Writable Elements for results

Element Type Required Constraints Description

author

String

 

1 or more characters

Name of the query author

resourceId

       

serviceId

       

title

       

description

String

No

1 or more characters

Description of the query

lastModifiedDate

       

size

       

Resource Types Linked to From results

Table 45-5 lists the resource types that the client can link to from this resource.

Table 45-5 Related Resource Types for search

rel resourceType

self

 

45.3.8 Using the Search Service Data Control

Use the Search service data control to build a customized search user interface with a Framework application or a custom task flow. Deploying this task flow into an ADF library allows for a portable consumption of the task flow; for example, you could add it to a WebCenter Portal: Spaces application Resource Catalog to build site templates.

45.3.8.1 Search Data Control Methods, Attributes, and Classes

The Search data control contains the searchSes method. Table 45-6 describes its parameters for setting search refiners and limiting the scope of the search.

Table 45-6 searchSes Input Parameters

Parameter Required? Type Description

scopeGuid

No

String

GUID value to filter results by spaces.

serviceId

No

String

The service ID of the item; for example, oracle.webcenter.doclib searches only documents. If omitted, this searches across all services.

keywords

Yes

String

Search terms.

predicates

No

List

Collection of predicates.

fetchRefiners

No

Boolean

Whether to fetch refiners. If omitted, the default value is false.

startIndex

Yes

Integer

Specifies the index of the first matching result that should be included in the result set (0-n ... zero based). This is used for pagination.

itemsPerPage

Yes

Integer

Number of results to display.


The searchSes method returns:

45.3.8.1.1 SearchServiceDCRows
  • author

  • comments

  • createDate

  • description

  • iconPath

  • language

  • largeIconPath

  • lastModifiedDate

  • resourceId

  • scopeGuid

  • serviceId

  • size

  • tagWords

  • title

  • type

  • urlSearchServiceDCRefiner

45.3.8.1.2 SearchServiceDCRefiner

element

45.3.8.1.3 SearchServiceDCRefinement
  • keywords

  • scopeGuid

  • serviceId

  • Collection of predicates

45.3.8.2 Integrating the Search Data Control

To use the Search data control:

  1. In JDeveloper, create a Framework application with an Oracle SES connection. After the connection is available, the Search Data Control is listed in the Data Controls palette.

  2. Drag and drop the searchSes method from SearchServiceDC.

  3. Choose ADF Parameter Form, and the Edit Form Fields dialog opens. Click OK.

  4. Drag the rows accessor, from the SearchServiceDCResult return object type, onto the form, and choose Table - ADF Read-only Table. Click OK.

  5. Run the page, enter appropriate values. For example:

    • keywords: any search term

    • startIndex: 0

    • itemsPerPage: 10

For information about adding data controls to your application, see Section 7.1.2, "Understanding WebCenter Portal APIs."

45.3.9 Building Adapters for the Search Service

You can use search adapters to add other sources to your search results. WebCenter Portal framework automatically discovers these search adapters and consolidates them in formulating search results in your application. Subsequently, when you expose your custom component to the Search service in your application, it is included in the federated search.

This section describes how to extend WebCenter Portal's search through search adapters. It includes the following subsections:

45.3.9.1 How to Add a Search Source

To add a new search source, you must create Java classes for the new source to manage the incoming queries and return search results. After you add the necessary Java classes to your application, you must register them with the Search service.

When performing a search, the search framework calls QueryManager.createRowQueryHandler with a query object and a List<QName> that describes the columns sought. In return, the framework receives a QueryHandler<Row>.

A QueryHandler can be a QueryFederator or a QueryExecutor. A QueryFederator is just a collection of other QueryHandlers. With the QueryFederator, the framework can get a list of the child QueryHandlers and keep recursing until all QueryExecutors are found.

The framework calls the execute method on the QueryExecutor to get a QueryResult<Row>, which is an extension of java.util.Iterator<Row> that iterates and retrieves rows of results.

One possible implementation would be to create these classes:

  • SampleQueryManager ...

  • SampleRowQueryExecutor ...

  • SampleRowQueryResult ...

  • SampleRow ...

To add a new search source with a similar query manager:

  1. In Oracle JDeveloper, open the application in which to add the search source.

  2. Confirm that the WebCenter Common library is included in your project:

    1. In the Application Navigator, right-click your project and select Project Properties and then Libraries and Classpath.

    2. If the WebCenter Common library is not included, as shown in Figure 45-8, then click Add Library and select it.

      Figure 45-8 WebCenter Common Library

      Description of Figure 45-8 follows
      Description of "Figure 45-8 WebCenter Common Library"

    3. Click OK.

  3. Create a class called SampleQueryManager.java (Example 45-5).

    Example 45-5 SampleQueryManager.java

    package mycompany.myproduct.myapp.mycomponent.query;
    import java.util.List;
    import oracle.webcenter.search.QName;
    import oracle.webcenter.search.Query;
    import oracle.webcenter.search.QueryExecutor;
    import oracle.webcenter.search.QueryManager;
    import oracle.webcenter.search.Row;
    public class SampleQueryManager
      implements QueryManager
    {
      public SampleQueryManager()
      {
      }
      public QueryExecutor<Row> createRowQueryHandler(Query query,
                                                      List<QName> columns)
      {
        return new SampleRowQueryExecutor(query, columns);
      }
    }
    
  4. Create a class called SampleRowQueryExecutor.java (Example 45-6).

    Example 45-6 SampleRowQueryExecutor.java

    package mycompany.myproduct.myapp.mycomponent.query;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import static oracle.webcenter.search.AttributeConstants.DCMI_EXTENT;
    import static oracle.webcenter.search.AttributeConstants.DCMI_MODIFIED;
    import static oracle.webcenter.search.AttributeConstants.DCMI_CREATOR;
    import static oracle.webcenter.search.AttributeConstants.DCMI_TITLE;
    import static oracle.webcenter.search.AttributeConstants.DCMI_URI;
    import static oracle.webcenter.search.AttributeConstants.DCMI_IDENTIFIER;
    import static oracle.webcenter.search.AttributeConstants.WPSAPI_ICON_PATH;
    import oracle.webcenter.search.QName;
    import oracle.webcenter.search.Query;
    import oracle.webcenter.search.QueryExecutor;
    import oracle.webcenter.search.QueryHandler;
    import oracle.webcenter.search.QueryResult;
    import oracle.webcenter.search.Row;
    public class SampleRowQueryExecutor
      implements QueryExecutor<Row>
    {
      private static final int PRESET_ESTIMATED_RESULT_COUNT = 10;
      private static final int PRESET_VALUES_BATCH_SIZE = 5;
      private static final int MAX_RESULT_LIMIT = 100;
      private int m_resultStart;
      private int m_resultLimit;
      private Query m_query;
      private List<QName> m_columns;
      private Map<String, String> m_properties;
      public SampleRowQueryExecutor(Query query, List<QName> columns)
      {
        m_query = query;
        m_columns = columns;
        m_properties = new HashMap<String, String>();
        // In actuality you may want to make sure this string is translatable
        m_properties.put(QueryHandler.TITLE, "Sample");
      }
      /**
       * Create several rows for "batchRepeat" times.
       */
      private static void createRows(List<Row> rows, int batchRepeat)
      {
        while (batchRepeat-- > 0)
        {
          rows.add(new SampleRow("23847", "Initial Sorting of Tables", 
                                 "Bar", "2006-06-08", 5120));
          rows.add(new SampleRow("4827445", "Support for facelets?", 
                                 "Foo", "2006-04-17", 1400000));
          rows.add(new SampleRow("952787", "For Thomas Kincade's validation demo", 
                                 "Tiger", "2006-01-09", 1300000));
          rows.add(new SampleRow("4394588", "Page not showing in WYSIWYG fashion",
                                 "Ken Swartz", "2006-04-27", 3000));
          rows.add(new SampleRow("3920", "Tree table", 
                                 "Scott", "2006-03-24", 1200));    
        }
      }
      /**
       * Instead of doing a query execution here, 
       * just create a bunch of rows.
       */
      public QueryResult<Row> execute()
      {
        List<Row> rows = new ArrayList<Row>();
        // To hit a certain count here but not go over the max
        int realLimit = Math.min(MAX_RESULT_LIMIT, m_resultLimit);
        createRows(rows, (realLimit / PRESET_VALUES_BATCH_SIZE));
        // Create the QueryResult
        QueryResult<Row> ret = new SampleRowQueryResult(rows.iterator());
        ret.getProperties().put(QueryResult.ESTIMATED_RESULT_COUNT, 
                                Integer.toString(PRESET_ESTIMATED_RESULT_COUNT));
        return ret;
      }
      /**
       * Remember the result start.
       */
      public void setResultStart(int resultStart)
      {
        m_resultStart = resultStart;
      }
      /**
       * Store away the result limit to use in the execute
       * to only get that number of results back.
       */
      public void setResultLimit(int resultLimit)
      {
        m_resultLimit = resultLimit;
      }
      /**
       * Expose our properties map containing our title.
       */
      public Map<String, String> getProperties()
      {
        return m_properties;
      }
    }
    
  5. Create a class called SampleRowQueryResult.java (Example 45-7).

    Example 45-7 SampleRowQueryResult.java

    package mycompany.myproduct.myapp.mycomponent.query;
    import java.util.Iterator;
    import oracle.webcenter.search.util.WrapperQueryResult;
    import oracle.webcenter.search.Row;
    public class SampleRowQueryResult extends WrapperQueryResult<Row>
    {
      public SampleRowQueryResult(Iterator<Row> rows)
      {
        super(rows);
      }
    }
    
  6. Create a class called SampleRow.java (Example 45-8).

    Example 45-8 SampleRow.java

    package mycompany.myproduct.myapp.mycomponent.query;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import oracle.webcenter.search.QName;
    import oracle.webcenter.search.Row;
    import static oracle.webcenter.search.AttributeConstants.DCMI_EXTENT;
    import static oracle.webcenter.search.AttributeConstants.DCMI_MODIFIED;
    import static oracle.webcenter.search.AttributeConstants.DCMI_CREATOR;
    import static oracle.webcenter.search.AttributeConstants.DCMI_TITLE;
    import static oracle.webcenter.search.AttributeConstants.DCMI_URI;
    import static oracle.webcenter.search.AttributeConstants.DCMI_IDENTIFIER;
    import static oracle.webcenter.search.AttributeConstants.WPSAPI_ICON_PATH;
    public class SampleRow implements Row
    {
      private Map<QName, Object> m_storage = new HashMap<QName, Object>();
      private DateFormat m_dateFormat = new SimpleDateFormat("yyyy-MM-dd");
      SampleRow(String id, String title, 
                String creator, String lastModified,
                int size)
      {
        m_storage.put(DCMI_IDENTIFIER, id);
        // Only if you have an external URL to go to
        // m_storage.put(DCMI_URI, "http://my.external.url");
        m_storage.put(DCMI_TITLE, title);
        m_storage.put(DCMI_CREATOR, creator);
        // The below path points to a path accessible in the classpath to an icon
        m_storage.put(WPSAPI_ICON_PATH, "/adf/webcenter/search_qualifier.png");
        try
        {
          Date date = m_dateFormat.parse(lastModified);
          Calendar cal = Calendar.getInstance();
          cal.setTime(date);
          m_storage.put(DCMI_MODIFIED, cal);
        }
        catch (ParseException e)
        {
          e.printStackTrace();
        }
        m_storage.put(DCMI_EXTENT, new Long(size));
      }
      public Object getObject(QName columnName)
      {
        return m_storage.get(columnName);
      }
      public Iterator<QName> getColumns()
      {
        return m_storage.keySet().iterator();
      }
    }
    

45.3.9.2 How to Register a Custom Adapter

To register your query manager with the Search service, you must edit the service-definition.xml file. The SampleQueryManager line exposes the custom adapter's query manager implementation to the Search service so that the custom adapter is included with any search user interface.

The entry should be similar to Example 45-9.

Example 45-9 Sample Query Manager Entry in service-definition.xml

<service-definition id="mycompany.myproduct.myapp.mycomponent"
   version="11.1.1.0.0">
  <resource-view taskFlowId="/somepath/somefile.xml#someId"
                    authorizerClass="some.service.id.Authorizer1"/>
  <name>Custom Component 1</name>
  <description>Description for Custom Component 1</description>
  <search-definition xmlns="http://xmlns.oracle.com/webcenter/search"
      id="mycompany.myproduct.myapp.mycomponent.query" version="11.1.1.0.0">
  <query-manager-class>
mycompany.myproduct.myapp.mycomponent.query.SampleQueryManager
  </query-manager-class>
  </search-definition>
</service-definition>

For more information about the resource-view tag (and WebCenter Portal's Resource Action Handling framework), see Section 7.3, "Extending Your Framework Application with Custom Components."

45.3.9.3 Search Adapter Attributes

This section describes the attributes available for searching a service. It includes the following subsections:

45.3.9.3.1 Searchable Attributes

WebCenter Portal's search user interface exposes searches based on three fields: keywords, date, and person. Each service, in its own search implementation, honors these fields to the best of its capabilities. At minimum, it supports the keywords field. When you define your own search adapter, you must honor these fields to the best of your adapter's capabilities, as described in Section 45.3.9.3.8, "Selectable Attributes."

45.3.9.3.2 Keywords

By default, the keyword field is in oracle.webcenter.search.TextPredicate. The field can comprise multiple words, with the service determining how to interpret multiple words. The Search service does not tokenize before the call comes to the service, but here are some guidelines:

  • If two or more tokens are enclosed within quotes, then they should be interpreted as one word.

  • Unless the OR operator is explicitly set, it is assumed that the default conjunction among the words in the keywords field is AND.

45.3.9.3.3 Date Condition

For Search service to support filtering of query results by last modified date, the service implementation of the WPSAPI must support the use of oracle.webcenter.search.AttributePredicate, accessible from the query object, that uses oracle.webcenter.search.AttributeConstants.DCMI_MODIFIED. The supported comparators must include the following:

  • oracle.webcenter.search.ComparatorConstants.GREATER_THAN

  • oracle.webcenter.search.ComparatorConstants.GREATER_THAN_OR_EQUALS

They may also include the following:

  • oracle.webcenter.search.ComparatorConstants.EQUALS

  • oracle.webcenter.search.ComparatorConstants.NOT_EQUALS

  • oracle.webcenter.search.ComparatorConstants.LESS_THAN

  • oracle.webcenter.search.ComparatorConstants.LESS_THAN_OR_EQUALS

The literals for comparison should be of type java.util.Calendar.

45.3.9.3.4 Complex Date Condition

You can use the BETWEEN clause for dates. The complex date condition, instead of being a simple AttributePredicate, is a ComplexPredicate that contains one GREATER_THAN AttributePredicate and one LESS_THAN AttributePredicate with an AND conjunction operator. This ComplexPredicate must apply the AND operator with the rest of the fields (that is, keywords and person).

To differentiate between this case and the default case, service authors must check on the type of the predicate that is meant for the date condition. If it is an AttributePredicate, then it is the default case. If it is a ComplexPredicate, then it is a special case.

45.3.9.3.5 Person Condition

For Search to support filtering of query results by person, the service implementation of the WPSAPI must support oracle.webcenter.search.AttributePredicate, accessible from the query object, that uses oracle.webcenter.search.AttributeConstants.WPSAPI_MODIFIER.

The comparators supported must include the following:

  • oracle.webcenter.search.ComparatorConstants.EQUALS

  • oracle.webcenter.search.ComparatorConstants.CONTAINS

  • oracle.webcenter.search.ComparatorConstants.STARTS_WITH

  • oracle.webcenter.search.ComparatorConstants.ENDS_WITH

The literals for comparison should be of type java.lang.String.

45.3.9.3.6 Complex Person Condition

Service authors must check on the type of predicate that is meant for the person condition. An AttributePredicate is the default case.

45.3.9.3.7 Access

The Search service (as a caller) expects that the query's getPredicate() method likely returns an oracle.webcenter.search.ComplexPredicate that joins an oracle.webcenter.search.TextPredicate holding the keyword, and an oracle.webcenter.search.ComplexPredicate holding the date condition, and an oracle.webcenter.search.AttributePredicate holding the person condition.

45.3.9.3.8 Selectable Attributes

The following selectable attributes/columns should be supported by your search adapter in its search implementation:

  • Title (Required)

    For each resource returned, the Search service user interface can display the title column, if provided. It is strongly recommended that the title column comes with the QName AttributeConstants.DCMI_TITLE.

  • Resource ID (Required)

    For resources to communicate a unique identifier that allows the Search service to render a link to navigate to the resource view (or any declared views) of the service, the column with the name oracle.webcenter.search.AttributeConstants.DCMI_IDENTIFIER must be returned as a column accessible from a row within the QueryResult<Row>.

    The Search service extracts the DCMI_IDENTIFIER column and feeds it into the resource viewer as the value of the resourceId parameter when the link is clicked.

    If your resource view (or any declared views) requires multiple columns in the primary key, then try to bundle all of them into a composite string value for the oracle.webcenter.search.AttributeConstants.DCMI_IDENTIFIER column. The Search service treats that opaquely and passes it to your resource view, within which it may deconstruct the string into the various parts of the primary key.

  • Resource Type

    For each resource returned, the Search service user interface can display the type column, if provided. The type column comes with the QName AttributeConstants.DCMI_TYPE. If the DCMI_TYPE column is not found, then the value of the DCMI_FORMAT column is used in its place. In your resource viewer, you can make use of the resource type to aid in the rendering of a resource.

  • Resource URL (in place of Resource ID)

    In the absence of an oracle.webcenter.search.AttributeConstants.DCMI_IDENTIFIER column, WebCenter Portal's Search service constructs the link from the value of the column specified by oracle.webcenter.search.AttributeConstants.DCMI_URI. With absolute URLs, the DCMI_URI can launch a link from the search results to the URL.

    This allows for services, such as the Documents service and the Page service, to invoke the browser plug-in to render various results link targets, instead of invoking a resource view.

  • Last Modified Date

    For each resource returned, the Search service user interface can display the last modified date column, if provided. To mirror the searchable attribute of the last modified date, it is important that users can see the last modified date as a returned column in the search result.

    For most users, the last modified date is more relevant than the creation date. To have better consistency between the searchable attributes and the selectable attributes (so that users know what date to search with after seeing some values in the columns), it is strongly recommended that service authors return AttributeConstants.DCMI_MODIFIED rather than AttributeConstants.DCMI_CREATED. The last modified date is of type java.util.Calendar.

  • Creator

    For each resource returned, the Search service user interface can display the creator and last modified by column, if provided. The search user interface combines them in the same column as a list of contributors for the found resource. The QNames to use are AttributeConstants.DCMI_CREATOR and AttributeConstants.WPSAPI_MODIFIED, respectively. The creator is of type java.lang.String.

  • Icon

    For each resource returned, the Search service user interface can display the icon column, if provided. The icon column comes with the QName AttributeConstants.WPSAPI_ICON_PATH and corresponds to a valid path to an icon file that is accessible in the class path. The icon path is of type java.lang.String.

  • Size

    For each resource returned, the Search service user interface can display the size column, if provided. The size column comes with the QName AttributeConstants.DCMI_EXTENT and corresponds to the size of the resource found. The size is of type java.lang.Number.

45.3.9.4 What Happens at Runtime

When you perform a search from the main view or toolbar, it should seamlessly include your new search source. For testing purposes, be sure to enter criteria that yields a result in your newly-added search source.

WebCenter Portal's Search service invokes a resource viewer using the Resource Action Handling framework. For information about registering a resource viewer to allow custom components to be found using Search, see Section 7.3, "Extending Your Framework Application with Custom Components."

45.3.10 Customizing the Search UI Without WebCenter Portal's Search Service APIs

You can develop a custom search user interface in a Framework application without WebCenter Portal's Search service API, but still with Oracle SES as the application's search engine by using the Oracle SES Web Service Query API to do search functions. Also, action handling for search results can be managed with WebCenter Portal's Resource Action Handling framework, so that when an application resource (for example, a document) is clicked in the search results, the resource is shown in the viewer of the resource (for example, the Documents resource viewer). Moreover, if the application uses WebCenter Portal Navigation, then certain resource types can be shown in the navigation node of the resource.

This section describes the required steps to enable Resource Action Handling for handling search result action.

  1. Use the Document Service Manager provided by WebCenter Portal to crawl documents.

    The Document Services Manager creates an attribute called wc_url in the Oracle SES index for each document. The value of the wc_url attribute is a URL that goes to the Resource Action Handling module of the application. The URL uses the value of the WebCenter URL Prefix parameter in the Document Service instance as the prefix.

    Set the parameter value as the host and port where the application is deployed, plus the context root; for example:

    http://myhost:8888/DocumentsServer
    
  2. Use the wc_url attribute for action handling in the search UI.

    Typically, the search UI uses the URL attribute for action handling. To use Resource Action Handling for action handling of search results of the Documents resource type, use the wc_url attribute. Note that only search results with the Documents resource type have the wc_url attribute. Therefore, this must be done conditionally in the search UI code.

  3. Specify WebCenter Portal's Resource Action Handling class for click action of search result.

    When a search result is clicked, the resource is rendered in the resource viewer of the resource, if available. The current search results page is over-written. Use Resource Action Framework to change this behavior.

    Update the adf-config.xml file of the application to specify the Resource Action Handling class to use.

    Example 45-10 shows how to use PopUpResourceActionViewHandler to show the resource in a popup window when a search result is clicked.

    Example 45-10 Specifying PopUp Behavior Handler

    xmlns:wpsC="http://xmlns.oracle.com/webcenter/framework/service"
      <wpsC:adf-service-config xmlns="http://xmlns.oracle.com/webcenter/framework/service">
        <resource-handler class="oracle.webcenter.framework.resource.view.PopUpResourceActionHandler"/>
      </wpsC:adf-service-config>
    

    Example 45-11 shows how to use NavigationResourceActionHandler to show the resource in the navigation node of the resource when a search result is clicked.

    Example 45-11 Specifying the Navigation Handler

    xmlns:wpsC="http://xmlns.oracle.com/webcenter/framework/service"
      <wpsC:adf-service-config xmlns="http://xmlns.oracle.com/webcenter/framework/service">
        <resource-handler class="oracle.webcenter.portalframework.sitestructure.handler.NavigationResourceActionHandler"/>
      </wpsC:adf-service-config>
    

45.3.11 Troubleshooting the Search Service

This section describes common problems and solutions for the Search service.

Problem

There is a set timeout for querying each service. If a particular service does not return search results in the allotted time, then it times out. The Announcements and Discussions services are susceptible to timeouts. (In WebCenter Portal: Spaces, pages and spaces could have timeouts from search execution.)

Solution

To improve performance at design time, you can increase the values (in milliseconds) of timeoutMs and prepare TimeoutMs in adf-config.xml. The following is the relevant fragment of adf-config.xml, found in the Application Resources panel in the ADF META-INF folder:

<execution-properties timeoutMs="3000"prepare TimeoutMs="1000"/>

At runtime, you can configure timeouts using WLST or Fusion Middleware Control.