Switch Between the Database and Elasticsearch Search Engines

On this page

FusionAuth searches Users and Entities with either the database search engine or the elasticsearch search engine. The elasticsearch search engine works with OpenSearch and Elasticsearch. You can switch engines at any time. For the differences between the engines, see Search Engines.

Every switch takes a restart, so plan for a short outage. For instructions on stopping and starting FusionAuth, see Start and Stop a Production Instance.

The steps on this page set configuration in fusionauth.properties or in environment variables. For every search setting, see the Configuration Reference.

Switch to the Elasticsearch Search Engine#

Before you start, install OpenSearch or Elasticsearch, and confirm that FusionAuth can reach the search engine. For instructions, see Install a Search Engine.

Check that each field in your data objects holds one data type across all objects. The Elasticsearch search engine skips objects with mismatched types when the engine indexes the objects. For more information, see Data Field Types.

  1. Stop FusionAuth.

  2. Set the search engine type and the search engine URL:

    search.type=elasticsearch
    search.servers=http://localhost:9200
    
    SEARCH_TYPE=elasticsearch
    SEARCH_SERVERS=http://localhost:9200
    
  3. Start FusionAuth.

  4. In the Admin UI, navigate to System -> About . The Search row shows OpenSearch or Elasticsearch, and the version.

  5. Navigate to System -> Reindex , set Select an index to User, type REINDEX in Confirm, and click Save . When you use Entities, repeat with Entity. The new index is empty, so searches miss existing Users and Entities until the reindex finishes. A reindex takes longer with more Users and more custom data. For more information, see Reindex.

  6. Navigate to Users , and search for a User by email address. The Advanced search link appears below the search field.

Switch to the Database Search Engine#

  1. Stop FusionAuth.

  2. Set the search engine type to database:

    search.type=database
    
    SEARCH_TYPE=database
    

    FusionAuth ignores search.servers with the database search engine, so you can leave the setting in place.

  3. Start FusionAuth.

  4. In the Admin UI, navigate to System -> About . The Search row shows Database.

  5. Navigate to Users , and search for a User by email address.

FusionAuth stops sending data to OpenSearch or Elasticsearch, and you can shut the search engine down. After the switch, requests with the query parameter return a 400 response, and FusionAuth doesn't support SCIM filters. For the full list of features that need the Elasticsearch search engine, see Search Engines.

The Users page in the Admin UI with the database search engine, showing a search field without the Advanced link.
The Users page in the Admin UI with the database search engine, showing a search field without the Advanced link.