Nuxeo Search Center

Table of Contents

65.1. Overview
65.2. Installing and testing the search center
65.2.1. Building from source
65.2.2. Deploying on a Nuxeo server
65.2.3. Using the Search Center
65.3. How does it work
65.3.1. The GWT client
65.3.2. The JAX-RS server
65.3.3. The SearchCenterService
65.4. How to customize the list of available filters
65.4.1. FilterWidgets
65.4.2. FilterSets
65.5. How to build new GWT filter widgets
65.5.1. Setting up a GWT eclipse development environment
65.5.2. Existing filter widgets
65.5.3. TODO: layout and extension points

This chapter presents the architecture of the nuxeo-searchcenter GWT client to the Search Service (new in Nuxeo 5.2).

65.1. Overview

The Nuxeo Search Center is a standalone GWT application that can be deployed on a Webengine site in order to provide an AJAX interface to perform queries on the document repository.

TODO: add a screenshot here

65.2. Installing and testing the search center

65.2.1. Building from source

First of all, Nuxeo Search Center depends on nuxeo-gwt modules, so the first thing to do is to build and install the nuxeo-gwt projects.

hg clone https://hg.nuxeo.org/nuxeo/nuxeo-gwt
cd nuxeo-gwt
mvn clean install

Then you need the Nuxeo Search Center projects.

hg clone https://hg.nuxeo.org/nuxeo-searchcenter
cd nuxeo-searchcenter
mvn clean install

65.2.2. Deploying on a Nuxeo server

To get the Nuxeo Search Center working on Nuxeo, only those 3 jars are needed:

  • nuxeo-gwt-server-5.2-xxx.jar

  • nuxeo-searchcenter-gwt-app-5.2-xxx.jar

  • nuxeo-searchcenter-service-5.2-xxx.jar

To deploy it, drop these 3 jars:

  • in nuxeo.ear/plugins on JBoss.

  • in bundles on Webengine standalone (Jetty).

Restart your server, and you can access Nuxeo Search Center at the following urls:

  • http://localhost:8080/nuxeo/site/searchcenter on JBoss.

  • http://localhost:8080/searchcenter on Webengine standalone (Jetty).

The Nuxeo Search Center application is also listed with the others Webengine applications at http://localhost:8080/nuxeo/site or http://localhost:8080/.

65.2.3. Using the Search Center

TODO: go to http://localhost:8080/site/ and ... .

65.2.3.1. Save/Load FilterSet

The current search can be saved from the graphical interface. It will send the current FilterSet, which contains all the FilterWidgets descriptions and their values, to the SearchCenterService. The FilterSet is saved as a DocumentModel on the user personnal Workspace (cf. nuxeo-platform-userworkspace add-on).

A ComboBox lists all the available FilterSets : the contributed ones and the saved ones which the current user can access. When a FilterSet is selected and the load button pressed, the list of FilterWidgets is rebuild, their default values are setted and the query is regenerated and executed.

65.2.3.2. TODO

TODO: Explain how to customize the list of available filter widgets (from the user interface).

65.3. How does it work

The Nuxeo Search Center application is composed of 3 different parts.

65.3.1. The GWT client

The UI part is built upon Google Web Toolkit, and particularly with SmartGWT

The client part lies in the nuxeo-searchcenter-gwt-app project.

65.3.2. The JAX-RS server

The JAX-RS part of Nuxeo Search Center lies in the class SearchCenterModule located in nuxeo-searchcenter-gwt-app/src/main/java/org/nuxeo/ecm/searchcenter/module.

Here are the main methods, defined in SearchCenterModule, used by Nuxeo Search Center:

  • getVocabulary, used to get the values list of a given simple vocabulary. It returns the list in a JSON format understandable by the SmartGWT widgets.

  • getHierarchicalVocabulary, used to get the values list of a given hierarchical vocabulary. It returns the list in a JSON format understandable by the SmartGWT widgets.

  • execQuery, used to create the Query from the list of filtering values, and execute it by calling the SearchCenterService. It returns a document list in a JSON format understandable by the SmartGWT widgets.

  • getFilterSet, used to get a FilterSet by its name or id. It returns a FilterSet description in a JSON format used to build the different widgets.

  • getFilterSets, used to get all the available FilterSets. It returns a list of FilterSet descriptions in a JSON format used to fill the FilterSet load ComboBox.

  • saveFilterSet, used to save the current search. It takes in parameter the JSON representation of the current FilterSet.

65.3.3. The SearchCenterService

The SearchCenterService is defined in the project nuxeo-searchcenter-service. Its purpose is to manage the FilterSets and FilterWidgets and generate and execute the QueryModel from the values entered by the user.

A helper class (SearchCenterHelper) is used to call the service methods and serialize the results in JSON format. This helper is called by some of the JAX-RS methods like execQuery and getFilterSet.

65.4. How to customize the list of available filters

65.4.1. FilterWidgets

To register a FilterWidget, you need to write a contribution with an extension to the SearchCenterService like :

<extension target="org.nuxeo.ecm.searchcenter.service.SearchCenterService" point="filterWidget">
  <filterWidget
    name="dc_subjects"
    index="dc:subjects"
    title="Subjects"
    type="hierarchicalVocabulary"
    vocabulary="topic" />
</extension>
  • The name attribute specifies a unique name for the FilterWidget. This name is used in FilterSet registrations.

  • The index attribute specifies the field in the associated where clause of the query.

  • The title attribute specifies the displayed title in the UI.

  • The type attribute specifies the type of the widget. The available widget types are :

    • string

    • date

    • vocabulary

    • hierarchicalVocabulary

  • The maxValues attribute is optional and specifies the number of maximum values the user can enter.

  • The operator attribute is optional and specifies the operator used in the corresponding where clause of the generated QueryModel. Default operator depends of the widget type :

    • string : if maxValues == 1, default operator is = else it is IN

    • date : default operator is BETWEEN

    • vocabulary and hierarchicalVocabulary : default operator is IN

  • The vocabulary attribute is only used by widgets of type vocabulary and hierarchicalVocabulary. It specifies the vocabulary which the values of the widgets are fetched from.

65.4.2. FilterSets

To register a FilterSet, you need to write a contribution with an extension to the SearchCenterService like :

<extension target="org.nuxeo.ecm.searchcenter.service.SearchCenterService" point="filterSet">
  <filterSet name="myFilterSet" title="My FilterSet" enabled="true">
    <filterSetItem widgetName="dc_creator" />
    <filterSetItem widgetName="dc_modified" />
  </filterSet>

  <fixedPart>ecm:primaryType != 'FilterSet' AND ecm:isCheckedInVersion = 0</fixedPart>
</extension>
  • The name attribute specifies a unique name for the FilterSet.

  • The title attribute specifies a display title for the FilterSet.

  • The enabled attribute is optional and allows to disable the FilterSet if set to false. Default value is true.

  • The filterSetItem tags designate the list of FilterWidgets the FilterSet contains.

    • The widgetName attribute refers to a FilterWidget name.

    • The hidden optional attribute allows to hide the specified widget. Default value is false.

  • The fixedPart tag can be used to add a fixed part to the generated where clause of the query.

65.5. How to build new GWT filter widgets

65.5.1. Setting up a GWT eclipse development environment

Inside the nuxeo-searchcenter directory, first run

mvn eclipse:eclipse

to setup the required files needed by eclipse to import the projects, then import the 2 projects in your workspace.

The simplest way to run and debug Nuxeo Search Center while developing is to use the GWT hosted mode.

  • Deploy Nuxeo Search Center on either JBoss or Jetty, and start the server.

  • inside the nuxeo-searchcenter-gwt-app, execute:

    mvn gwt:eclipse

    This will create an Eclipse launcher, org.nuxeo.ecm.searchcenter.gwt.SearchCenter.launch.

  • add -noserver to the arguments list of the new configuration.

Finally, run the configuration. After the connection was refused to http://localhost:8888, just put the url of the deployed Nuxeo Search Center: http://localhost:8080/nuxeo/site/searchcenter for JBoss, or http://localhost:8080/searchcenter for Jetty.

In order to write your own JAX-RS components in Groovy you might want to also install the Groovy eclipse plugin from the following update site: http://dist.codehaus.org/groovy/distributions/update/ although you can also write them in plain old Java too.

65.5.2. Existing filter widgets

There are 4 filter widgets bundled with Nuxeo Search Center:

  • StringFilterWidget: filter documents through arbitrary text entered by the user.

  • DateFilterWidget: filter documents via a Date interval

  • VocabularyFilterWidget: filter documents by selecting one or more value(s) among the configured simple vocabulary values.

  • HierarchicalVocabularyFilterWidget: filter documents by selecting one or more value(s) among the configured hierarchical vocabulary values.

Each widget instance is bound to a field in the Nuxeo documents. For instance, a String Filter Widget can be bound to the ecm:fulltext field, and a Date Filter Widget to the dc:created field.

These 4 widgets all extend VLayoutFilterWidget abstract class. This class is a convenient base class for the filter widgets you will develop. The VLayoutFilterWidget class provides:

  • a defaut layout for the widget composed of a title, a display list of the selected values and a form used to add new values.

    TODO: screenshot of a simple filter widget.

  • useful methods to add or remove filtering values with their associated rows in the display list.

  • a method refreshFilterSet which updates the current FilterSet and asks the application to refresh the documents list.

Your new filter widget class can extend VLayoutFilterWidget but it is not required. The only requirement is that your class extends FilterWidget so that it can be used by the different FilterView of the application.

The widgets are all built upon JSON Objects which contain at least the following attributes: type, name, title, hidden, all setted from the registered values in the FilterWidget and FilterSet definition.

Each widget extending VLayoutFilterWidgetcan be configured to accept a maximum number of values through the maxValues parameter.

65.5.3.  TODO: layout and extension points

TODO