Web App Framework 4

Solr Client

This module provides a Solr Client which can be used for connections and queries to a Solr Server.

Setup

To use the Sophora Web App Framework's Solr client, make sure to import the SolrSpringConfig (e.g. via auto configuration) to load all spring classes of this module.

Maven dependency

<dependency>
    <groupId>com.subshell.sophora.webapp</groupId>
    <artifactId>sophora-webapp-solr</artifactId>
    <version>x.y.z</version>
</dependency>

Configuration

To configure the Solr client you need to adapt your application.yml. All configuration parameters start with the solr prefix.

Parameters

Configuration Parameters
ParameterDescription
urlThe URL of the Solr server. May be left blank if zkhosts is used.
userSolr user name.
passwordSolr password.
cloudModeDetermines whether Solr Cloud is used. Default: false
zkhostsA comma separated list with no whitespace of at least one ZooKeeper host and port. Examples:

  • zookeeper1:2181
  • zookeeper1:2181,zookeeper2:2181
  • zookeeper1:2181,zookeeper1:2181/solr

May be left blank if url is used.
isLiveIn case the Solr Cloud is used, determines whether live collections (those with a "-live" prefix) shall be used for searching content. Default: false

Examples

solr:
    url: "https://solr.sophora.cms"
    user: "solr"
    password: "5012"
    live: false
solr:
    user: "solr"
    password: "5012"
    cloudMode: true
    zkHosts: solr-zookeeper-headless.sophora.cms,solr-zookeeper-headless.sophora.cms/solr
    live: true

Health Check

Since the default health check of the Apache SolrClient will fail because it searches for a local connection to a Solr Server, we need to disable it by adding the following configuration to the application.yml:

management:
    health:
        solr.enabled: false

Last modified on 8/8/22

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon