Written by The Jahia Team
 
Developers
   Estimated reading time:

This topic shows you how to:

  • Configure Elasticsearch storage and enable saving of submissions to an Elasticsearch server.
  • Migrate existing forms with results stored in the JCR.

Prerequisites

To store form results in Elasticsearch, you need:

  • A website that has Form Factory enabled.
  • Elasticsearch correctly configured in DX. If you have not done so, this install guide shows how to get up and running with DX and Elasticsearch.

Configuring Elasticsearch storage

To configure Elasticsearch as a datasource for submitted forms, you enable an Elasticsearch extension module for your web project and then enable Elasticsearch for a specific form. 

Enabling an extension module

To save results to Elasticsearch, you must deploy and enable an extension module containing this functionality on your site.

To enable the extension module:

  1. In DX, navigate to Administration>Web projects and edit the modules that deploy with the project.
  2. Add Form Factory Elasticsearch Storage (form-factory-elasticsearch-storage) to the list of deployed modules.
    add_module.png
  3. Choose Next to save your changes.

Enabling Elasticsearch for a form

To enable saving form submissions to an Elasticsearch datatable, you add a Save to Elasticsearch action to the form and specify an Elasticsearch database connection.

Note: You must that first configure the Elasticsearch database connection in Administration>Configuration>Database Connector.

To enable Elasticsearch for a form:

  1. In Form Factory Builder, choose the form that you want to save submissions for in Elasticsearch.
  2. In the Form Builder, click Action step 
    es-wrench-icon.png
    to show actions associated with the form.
  3. Click Add action 
    es-edit-action.png
    . In the side pane, select Save to Elasticsearch and click Close.
    select_action.png

    The Save to Elasticsearch action displays in the list of actions for the form.
  4. Next, specify the database connection for the action. Click Edit action 
    es-edit-action.png
    .
  5. In the Edit action pane, select an Elasticsearch connection from the Elasticsearch Connection list, as shown in the following example. Then, click Close.
    select_connection.png
  6. Click Save changes to form
    es-save-changes-to-form.png
    .
  7. Publish the form.

After publishing the form, form results are stored in Elasticsearch. Note that you can continue to use the Save to JCR action to store results in both data sources simultaneously.

Migrating form data from a JCR

You can migrate form results from a form that uses the JCR as a storage medium. 

To migrate form results from a JCR:

  • The form must have the Save to Elasticsearch action enabled and have submissions saved in the JCR
  • Your role requires the formFactoryResultsAdmin permission
Note: Once a migration has completed, further migrations are unavailable unless all indexes from the previous migration have been deleted.

To migrate form data from a JCR:

  1. Navigate to Site Settings>Form Factory>View/Exploit forms results and select Elasticsearch - Datatable for the form that you want to migrate.
    elasticsearch_result_view_selection.png

    The Elasticsearch option is only available if the form is published and has the Save to Elasticsearch action enabled.
  2. In the Elasticsearch results view page, select Start migration to start the migration.
    start_migration.png

When the migration completes, form results display in an Elasticsearch data table. You can now explore form results as you normally would.