Elastic Search Applications

edit

Search Applications enable users to build search-powered applications that leverage the full power of Elasticsearch and its Query DSL, with a simplified user experience. Create search applications based on your Elasticsearch indices, build queries using search templates, and easily preview your results directly in the Kibana Search UI.

You can also interact with your search applications using the Search Application APIs. Search Applications are designed to simplify building unified search experiences across a range of enterprise search use cases, using the Elastic platform.

Availability and prerequisites

edit

The Search Applications feature was introduced in Elastic version 8.8.0.

Search Applications is a beta feature. Beta features are subject to change and are not covered by the support SLA of general release (GA) features. Elastic plans to promote this feature to GA in a future release.

This feature is available to all Elastic Cloud deployments.

This feature is also available to self-managed deployments when Elastic subscription requirements are satisfied. View the requirements for this feature under the Elastic Search section of the Elastic Stack subscriptions page.

Your deployment must include the Elasticsearch and Kibana services.

Managing search applications requires the manage_search_application cluster privilege, and also requires the manage index privilege on all indices associated with the search application.

Overview

edit

The Elasticsearch Query DSL is powerful and flexible, but it comes with a steep learning curve. Complex queries are verbose and hard to understand for non-experts. We’ve designed search applications to be easier to search over, but with the flexibility of working with an Elasticsearch index.

Search Applications use search templates to simplify the process of building queries. Templates are defined when creating a search application, and can be customized according to your needs. Read Search API and templates for the details.

Get started

edit

Option 1: Get started in the UI

edit

You can create build, and manage your search applications directly in the Kibana UI under Search. Make sure you have at least one Elasticsearch index to work with on your deployment. The indices underlying your search application are searched together, similar to how an alias searches over multiple indices.

To create a new search application in Kibana:

  1. Go to Search > Search Applications.
  2. Select Create.
  3. Select the Elasticsearch indices you want to use for your search application.
  4. Name your search application.
  5. Select Create.

Your search application should now be available in the list of search applications.

Once created, you can explore the documents in your search application under Search > Search Applications > your-search-application > Docs Explorer. From there, you can expand a matching Elasticsearch document to see its full contents.

Option 2: Get started with the API

edit

Use the Elasticsearch Put Search Application API to create a search application.

The following example creates a search application named my_search_application that searches over the my_search_index1 and my_search_index2 indices, along with defining a simple search template (Refer to Default template example).

resp = client.search_application.put(
    name="my_search_application",
    search_application={
        "indices": [
            "my_search_index1",
            "my_search_index2"
        ],
        "template": {
            "script": {
                "source": {
                    "query": {
                        "query_string": {
                            "query": "{{query_string}}",
                            "default_field": "{{default_field}}"
                        }
                    }
                },
                "params": {
                    "query_string": "*",
                    "default_field": "*"
                }
            }
        }
    },
)
print(resp)
const response = await client.searchApplication.put({
  name: "my_search_application",
  search_application: {
    indices: ["my_search_index1", "my_search_index2"],
    template: {
      script: {
        source: {
          query: {
            query_string: {
              query: "{{query_string}}",
              default_field: "{{default_field}}",
            },
          },
        },
        params: {
          query_string: "*",
          default_field: "*",
        },
      },
    },
  },
});
console.log(response);
PUT /_application/search_application/my_search_application
{
  "indices": [ "my_search_index1", "my_search_index2" ],
  "template": {
    "script": {
      "source": {
        "query": {
          "query_string": {
            "query": "{{query_string}}",
            "default_field": "{{default_field}}"
          }
        }
      },
      "params": {
        "query_string": "*",
        "default_field": "*"
      }
    }
  }
}

Search templates

edit

Search templates are the heart of your search applications. The default template created for a search application is very minimal, and you’ll want to customize it to suit your needs. Search API and templates contains a number of examples to get you started, including the default template, as well as templates for text search, semantic search and hybrid search.