OpenSearch

OpenSearch is a standard format for sharing search results across different systems. It helps various search engines and search clients to communicate, by introducing a common set of formats for performing search requests and syndicating search results.

Note

Refer to the OpenSearch web site at http://www.opensearch.org for specifications and documentation.

Alfresco has adopted open standards throughout its framework, and OpenSearch is one such standard. This enables a standards-based interface for searching the content in the repository. For example, you can search the content in Alfresco from any application, which may be written in any other programming language and/or running on any other platform.

Alfresco exposes its search engines via OpenSearch and also provides a new aggregate open search feature in the Alfresco Explorer.

Alfresco's open search engines

You can see the available open search engines by navigating to the following URL, http://<servername>:<port>/alfresco/service/api/search/engines.

There are two open search engines available out of the box. One is a keyword (Google-like) search and the other is a person (registered member) search. Click on a specific Engine to view its description and usage.

Alfresco's open search engines

Keyword search description

This search is similar to the keyword search of the Alfresco Explorer. Documents containing the specified keywords in their name or content are returned.

The search URL format is as follows:

http://<servername>:<port>/alfresco/service/api/search/keyword?q={searchTerms}&p={startPage?}&c={count?}&l={language?}

The following parameters needs to be provided. The optional parameters are usually listed with a question mark.

  • searchTerms: keyword or keywords to search on
  • startPage (optional): the page number of the search results required by the client
  • count (optional): the number of search results per page (default: 10)
  • language (optional): the locale to search with (XML 1.0 Language Id, for example, en-GB)

The output response can either be in HTML, ATOM or RSS. The default output format is HTML.

Sample keyword search in HTML

Consider the following sample keyword search:

http://localhost:8080/alfresco/service/search/keyword.html?q=alfresco&c=5

In the URL, keyword.html indicates that the desired output is HTML. The search term is alfresco and the number of search results to be listed per page should be 5. The following screenshot displays the search results. If the search returns more results than the count specified (which is 5 in our example), then you will see links to subsequent results pages at the bottom of the screen.

Sample keyword search in HTML

Sample keyword search in RSS

You can also consider using the RSS output if you have the RSS reader, or if you would like to display the search results in a custom application, such as a Portal. The URL format remains the same, except that the file extension is rss.

Sample keyword search in RSS

The search interface is provided through Alfresco web scripts. You can customize the search result format by customizing these web scripts. More information about web scripts is provided in Chapter 9.

Alfresco Explorer as an OpenSearch aggregator

The Alfresco Explorer can be used as an OpenSearch aggregator in order to search across multiple repositories. When you log in to the Alfresco Explorer, you will notice the OpenSearch box on the left-hand side, along with a navigation window.

Alfresco Explorer as an OpenSearch aggregator

Registering new search engines

New search engines can be registered with Alfresco by placing them in the <extension>/web-scripts-config-custom.xml file.

Let us register the following search engines with Alfresco.

  • Another external Alfresco server: If you have more than one Alfresco server installed in your organization, then this will be useful for searching content across multiple Alfresco repositories.
  • Yahoo search engine: Performs a search on the entire web for the given keyword, by using the Yahoo search engine.
  • Wikipedia: Performs a search of the Wikipedia database for the given keyword.

There is a sample file that you can use in the <extension> folder. Rename the sample file web-scripts-config-custom.xml.sample to web-scripts-config-custom.xml and edit it as follows.

<!--  File: extension/web-scripts-config-custom.xml        -->
<!--  Example configuration of multiple OpenSearch engines -->
<!--                                                       -->

<alfresco-config>

   <config evaluator="string-compare" condition="OpenSearch">
      <opensearch>
      
      <engines>
         
        <!--                                     -->
        <!--  Example: Remote Alfresco Server    -->
        <!--                                     -->
        <engine label="Remote Alfresco Repository" proxy="remote">
        <url type="application/atom+xml"> http://partners.alfresco.com/alfresco/api/service/search/keyword.atom?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest=true
        </url>
        <url type="application/rss+xml">                 http://partners.alfresco.com/alfresco/api/service/search/keyword.rss?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}&amp;guest=true
        </url>
        </engine>
            
        <!--                                     -->
        <!--  Example: Yahoo Search Engine       -->
        <!--                                     -->
	     <engine label="Yahoo Search" proxy="yahoo">
		  <url type="application/rss+xml">
http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&amp;query={searchTerms}&amp;start={startIndex?}&amp;results={count?}
	     </url>
	     </engine>
            
        <!--                                      -->
        <!--  Example: Registration of Wikipedia  -->
        <!--                                      -->
	     <engine label="Wikipedia Search" proxy="wikipedia">
		  <url type="application/rss+xml">
http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&amp;query={searchTerms}&amp;site=wikipedia.org&amp;start={startIndex?}&amp;results={count?}
	  	  </url>
	     </engine>
            
      </engines>
         
      </opensearch>
   </config>
   
</alfresco-config>

You can configure Alfresco's OpenSearch to directly submit the search request to the external search engine. It may be necessary to configure a search engine proxy. This means that the OpenSearch client indirectly submits a search request via the Alfresco Web Server (i.e. the proxy), rather than directly to the search engine. This is particularly useful in scenarios where the client is an AJAX-based browser, which is limited by cross-domain scripting locks.

Creating a search engine proxy is as simple as adding the proxy attribute to the engine configuration. The value of this attribute is a unique name that identifies the engine.

After creating and editing the web-scripts-config-custom.xml file, restart Alfresco.

Federated search

Log in to the Alfresco Explorer to view the OpenSearch features that you have added. You will notice the new entries for Remote Alfresco Repository, Yahoo Search, and Wikipedia Search. When you search for keywords, the search is federated across multiple content sources and unified results are provided, as shown in the following screenshot:

Federated search
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset