Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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
Appearance settings

A Spring FactoryBean for Solr 5.x clients.

License

NotificationsYou must be signed in to change notification settings

Indoqa/solr-spring-client

Repository files navigation

This project offers a Spring based implementation of a FactoryBean for communicating with Apache Solr servers.

The SolrClientFactory allows to communicate with Solr either embedded, via http or Apache ZooKeeper for SolrCloud installations.

The desired behavior is configured with the supplied url:

  • file:// - uses the EmbeddedSolrClient
  • http:// - uses the HttpSolrClient
  • cloud:// - uses the CloudSolrClient

Installation

Requirements

  • Apache Solr 8.0+
  • Spring Beans 4.1+
  • Java 8+

Build

  • Download the latest release via maven
    <dependency>      <groupId>com.indoqa.solr</groupId>      <artifactId>solr-spring-client</artifactId>    </dependency>
  • Download source
  • run "maven clean install"

Configuration

Initialize the SolrClientFactory for tests with this snippet

SolrClientFactorysolrClientFactory =newSolrClientFactory();solrClientFactory.setUrl("file:///tmp/solr-spring-server/embedded-test-core");solrClientFactory.setEmbeddedSolrConfigurationDir("./src/test/resources/solr/test-core");solrClientFactory.initialize();SolrServersolrServer =solrClientFactory.getObject();QueryResponseresponse =solrServer.query(newSolrQuery("*:*"));    ...solrServer.shutdown();solrClientFactory.destroy();

The url can either be a relative or absolute directory, the embeddedSolrConfigurationDir must include the usual Solr configuration files:

  • schema.xml
  • solrconfig.xml

To communicate with a single Solr server use this snippet

SolrClientFactorysolrClientFactory =newSolrClientFactory();solrClientFactory.setUrl("http://localhost:8983/test-core");solrClientFactory.initialize();

To communicate with a SolrCloud cluster use this snippet

SolrClientFactorysolrClientFactory =newSolrClientFactory();solrClientFactory.setUrl("cloud://zkHost1:2181,zkHost2:2182?collection=test-collection");solrClientFactory.initialize();

The syntax uses zkHost1:2181,zkHost2:2182 for the ZooKeeper instances in your ZooKeeper ensemble, followed by the collection to be used.This ensures that the communication for update requests will be established against the leader of the collection to minimize communication overhead.

Solr Spring server integration based on xml configuration

   <beanname="solrClientFactory"class="com.indoqa.solr.server.factory.SolrClientFactory">     <propertyname="url"value="file://./target/solr/embedded-test-core" />     <propertyname="embeddedSolrConfigurationDir"value="./src/test/resources/solr/test-core" />   </bean>

About

A Spring FactoryBean for Solr 5.x clients.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp