Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Oct 30, 2023. It is now read-only.
/solrlibPublic archive

A convenience library for Solr/SolrJ

License

NotificationsYou must be signed in to change notification settings

redlink-gmbh/solrlib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

an easy to use solr client, that works embedded or with SolrServer and SolrCloud.

Build StatusMaven CentralSonatype (Snapshots)Javadocs

SolrLib aims to ease the use ofApache Solr within Java applications.

Often you want to internally use Solr -SolrLib helps launching up an embedded CoreContainer. The big advantage: Youkeep the core/collection configuration where it belongs - next to the code.If later, you want to switch to using an external Solr Server (classic or SolrCloud), you can do so without code-changes.SolrLib will evendeploy/update your collections on the remote instances.

Usage

<dependency>    <groupId>io.redlink.solrlib</groupId>    <artifactId>solrlib</artifactId>    <version>${VERSION}</version></dependency>

SolrLib is split up in several modules:

  • solrlib-api
  • solrlib-embedded
  • solrlib-standalone
  • solrlib-cloud

For convenience, there is also asolrlib-spring-boot-autoconfigure module for ease-of-use withinSpring Boot environments.

Cores/collections are registered by using aSolrCoreDescriptor, e.g. aSimpleCoreDescriptor:

// Create a core-descriptorCoreDescriptormyCore =newSimpleCoreDescriptor("my-core",Paths.get("/path/to/solr-conf"));// Create SolrCoreContainer and register CoreEmbeddedCoreContainerConfigurationconfig =newEmbeddedCoreContainerConfiguration();config.setHome(solrHome);config.setDeleteOnShutdown(true);SolrCoreContainercoreContainer =newEmbeddedCoreContainer(Collections.singleton(coreDescriptor),config,null);coreContainer.initialize();// ...// retrieve a SolrClienttry (SolrClientsolrClient =coreContainer.getSolrClient(myCore)) {solrClient.ping().getStatus();}

Embedded Mode

When usingsolrlib-embedded, an embedded CoreContainer will be launched. There is no directaccess to the Solr webservices or the admin-ui, you can retrieve anSolrClient to executequeries in your code.

Uponinitialize(), all registeredCoreDescriptors will be deployed.EmbeddedCoreContainerConfiguration.setDeleteOnShutdown controls if solr-home will be deleted uponshutdown.

Standalone Mode

When usingsolrlib-standalone,SolrLib connects to an external Solr server via http. Ifthe home-directory is configured, the registered cores are copied there and registered via theSolr Core Admin API. The configuration flagdeployCores chan further disable this.

Cloud Mode

Insolrlib-cloud,SolrLib connects to an SolrCloud ensemble via the provided zookeeper connectionstring.If the configuration flagdeployCores is set, all registered cores will be deployed to SolrCloudusingCloudSolrClient.uploadConfig.

NOTE: adding runtime-libraries from thelib folder is currently not supported!

Spring Boot

To useSolrLib in a Spring Boot environment, add the following dependencies to your project:

<dependencies><!-- Spring Boot Autoconfiguration for SolrLib-->    <dependency>        <groupId>io.redlink.solrlib</groupId>        <artifactId>solrlib-spring-boot-autoconfigure</artifactId>        <version>${solrlib.version}</version>    </dependency><!-- at least on implementation for runtime-->    <dependency>        <groupId>io.redlink.solrlib</groupId>        <artifactId>solrlib-embedded</artifactId>        <version>${solrlib.version}</version>        <scope>runtime</scope>    </dependency>    <dependency>        <groupId>io.redlink.solrlib</groupId>        <artifactId>solrlib-standalone</artifactId>        <version>${solrlib.version}</version>        <scope>runtime</scope>    </dependency>    <dependency>        <groupId>io.redlink.solrlib</groupId>        <artifactId>solrlib-cloud</artifactId>        <version>${solrlib.version}</version>        <scope>runtime</scope>    </dependency></dependencies>

The autoconfiguration checks solrlib with the following priority, the first one to match will be used:

  1. SolrLib Cloud (requiressolrlib.zk-connection to be set)
  2. SolrLib Standalone (requiressolrlib.base-url to be set)
  3. SolrLib Embedded (fallback)

All supported configuration properties forSolrLib:

# Used by embedded and standalone#      the ${SOLR_HOME} directorysolrlib.home = /path/to/solr/home# This will trigger using solrlib-standalone if available on the classpath#      base-url for all solr requestssolrlib.base-url = http://localhost:8983/solr# This will trigger using solrlib-cloud if available on the classpath#       ZooKeeper connection stringsolrlib.zk-connection = zookeeper1:8121,zookeeper2:8121# Only used by standalone and cloud#      prefix for the remote collection names,#      to avoid name-clashes on shared servers.solrlib.collection-prefix =# Only relevant in cloud-modesolrlib.max-shards-per-node = 1# Only used by standalone and cloud#      option to disable automatic configuration update/deployment#      to remote servers. You might not have the karma to do so.solrlib.deploy-cores = true# Only used by embedded#      option to delete the solrlib-home upon shutdownsolrlib.delete-on-shutdown = false

License

SolrLib is licensed under theApache License 2.0.

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp