Configuring Search

uPortal Search has the ability to search through portlet definitions, user information, portlet content, calendar, external web sites, Google Search Appliances, and other portlets that choose to participate in the search process to return useful information to the user.  The various components of the search are configurable, and pluggable.  Searches are performed via the search Launcher portlet (top-right of the authenticated user screen by default) and the Search portlet.

Configuring uPortal Search

Search is configured via several beans in the /uportal-war/src/main/resources/properties/contexts/servicesContext.xml file. 

Search Services

By default, the titles and descriptions of portlets in the portlet registry are included in the search.  You can uncomment the Google Search service (searches the web) or Google Search Appliance service (searches your University sites) to include those results in the search.

searchServices
    <util:list id="searchServices">
        <bean class="org.jasig.portal.portlets.search.portletregistry.PortletRegistrySearchService"/>
        
        <!-- Uncomment and fill in your Google Custom Search ID to use
        <bean class="org.jasig.portal.portlets.search.google.GoogleCustomSearchService">
            <property name="customSearchId" value="" />
        </bean>
         -->
         
        <!-- Uncomment and fill in your Google Search Appliance URL and Site to use
        <bean class="org.jasig.portal.portlets.search.gsa.GsaSearchService">
            <property name="baseUrl" value="http://search.example.com"/>
            <property name="site" value="Site"/>
        </bean>
        -->
    </util:list>

In addition, some Framework Portlets (portlets part of uPortal itself) have search integrated.

Framework PortletSearch Result Type valueConfiguration Notes
Directory PortletDirectoryConfiguring Directory Search, in particular the list directoryQueryAttributes

Displaying Search Results on different tabs

By default, all search results appear on the default search results tab.  You can display results from various search sources on different tabs by placing the search result type name in a map that has a message.properties code to identify the tab name to display.

search tabs
    <!-- 
     | Maps search resultType strings to tabs that are displayed in the results. If a resultType is not
     | mapped below its results go in the default tab.
     |
     | The key is the Messages.properties key to use for the result tab name 
     +-->
     <util:map id="searchTabs">
        <entry key="googleInstitution.results">
            <list>
                <value>googleCustom</value>
                <value>googleAppliance</value>
            </list>
        </entry>
    </util:map>

Configuring Search Auto-complete

With uPortal, searches support a configurable auto-complete feature that performs searches as you type and displays the results in an auto-complete list.  Configuration of this feature is in the same servicesContext.xml file.  You can configure the priority of results to display based on the result source.

Autocomplete prioritization
    <!--
     | For search auto-complete, indicate a set of priorities for each type of search result type.  Lower values
     | result in the search result appearing higher in the list (e.g. greater emphasis).
     |
     | Key: value set by the various Search services in the SearchResult.type field.
     |
     | Value: The value is the general priority for results of that type.  The default priority if not specified
     | is priority 0.  A positive value is lower than the default priority (i.e. de-emphasizes result),
     | and a negative value is higher than the default priority (e.g. emphasizes result).
     +-->
    <util:map id="searchAutocompletePriorityMap" value-type="java.lang.Integer">
        <entry key="Portlet List" value="-5"/>
        <entry key="Calendar" value="-2"/>
        <entry key="Directory" value="5"/>
        <!--<entry key="googleAppliance" value="0"/>-->
        <!--<entry key="googleCustom" value="0"/>-->
    </util:map>

In addition, if there are search result sources you do not want at all in the auto-complete search results, you can filter them out.

Removing results from autocomplete
    <!--
     | Set of the search result types to exclude from search autocompletion.  The value is the set by the
     | various Search services in the SearchResult.type field.
     +-->
    <util:set id="searchAutocompleteIgnoreResultTypes">
        <!--<value>Directory</value>-->
    </util:set>

There is also a portlet preference "autocompleteMaxTextSize" (defined in portlet.xml) that can be overridden in the portlet deployment xml file (or via the Manage Portlets admin UI) that allows you to specify how many characters are returned for both the auto-complete search result 'title' and 'description'.  You can change this preference to have more or less text in the auto-complete item entries.

Configuring Search Auto-suggest to use a single pre-populated list (enabled by default in uPortal 4.2.0+)

The Search Auto-suggest can be configured to use a single pre-populated source, such as only auto-suggest the list of portlets displayed in the gallery.  The advantage of a pre-populated list is that the UI experience is much quicker because the data is all local and uPortal does not have to be sent the query string after each keystroke. The disadvantage is that you cannot auto-suggest portlet content, users, etc. that are present in the portal since these depend on data external to uPortal or there is too much to return all of the data for local filtering.

To accomplish this, add and configure the following portlet preferences into your search launcher portlet definition (search-launcher.portlet-definition.xml – the quick search at the top-right) and/or the search portlet defintion (search.portlet-definition.xml).

<!-- Optional.  If specified indicates that the auto-complete search should use prepopulated source data
     and not query uPortal based on the user's entered keystrokes.  If not specified, the default search
     auto-suggest behavior occurs where auto-suggest queries uPortal with the field data entered by
     the user, which is slower but does a broader search within uPortal.  Specify a relative URL;
     e.g. for the portlet list used in the Gallery, enter /api/portletList.  The request path
     will be prepended. -->
<portlet-preference>
    <name>prepopulateAutoSuggestUrl</name>
    <value></value>
</portlet-preference>
<!-- If pre-populating auto-complete search results, this is the optional pattern for the resulting URL
     to display when the user selects an auto-complete search item.  The autoSuggestResultsProcessor can
     use this to craft an URL based on the selected item.  The request path will be prepended to this URL.
     For example, for the portlet list JSON returned by portlet list api, you would enter
     /p/$fname/max because the portletList autoSuggestResultsProcessor replaces $fname with the portlet
     fname from the portlet list JSON response. This is optional because not all
     autoSuggestResultsProcessors may need it. If the data returned from the prepopulateAutoSuggestUrl
     contains an URL, this preference would not need to be used.  -->
<portlet-preference>
    <name>prepopulateUrlPattern</name>
    <value></value>
</portlet-preference>
<!-- The name of the autoSuggestResultsProcessor method in autoSuggestResultsProcessors.js to use to
     process the JSON response from the prepopulateAutoSuggestUrl (if specified), or the default search
     auto-suggest Url. The default value is 'default' which is used with the default search auto-suggest
     feature. Other values, such as portletListProcessor are functions within
     autoSuggestResultsProcessors.js.  -->
<portlet-preference>
    <name>autoSuggestResultsProcessor</name>
    <value>default</value>
</portlet-preference>

Configuring link text to use published portlet title (uPortal 4.2.0+)

For portlets that participate in search but return static text for the link title, you can change which portlets have their link text replaced by modifying the set in servicesContext.xml

<!--
 | For search results create a set of search result types that will have the link text substituted with the
 | search match's portlet title.  Allows changing static text such as "cms" to the portlet definition title
 | so the results are more meaningful to the user.  UP-4266.
 +-->
<util:set id="searchResultsLinkNamePortletTitleSubstitutionSet" value-type="java.lang.String">
    <value>Portlet Content</value>  <!-- For SimpleCMS v1.08+ -->
</util:set>

 

Integrating portlets into uPortal Search

Portlets may search their contents and return results relevant to the search by incorporating SearchEvents into their design.  See the page Search API.

The portlets that participate in uPortal Search by default are present in search results and auto-complete searching.  To configure the tabs or auto-complete preferences for the portlet search results, you need to know the name the portlet assigns the search result type.  If it is not documented on the API page, you can search the portlet source code for "SearchResult" and look for something similar to the following code to find the string to use in the configuration above.

Setting type of search result
            searchResult.getType().add("Directory");