https://github.com/indoqa/solr-spring-client
A Spring FactoryBean for Solr 5.x clients.
https://github.com/indoqa/solr-spring-client
indoqa-library solr solr-client
Last synced: 6 months ago
JSON representation
A Spring FactoryBean for Solr 5.x clients.
- Host: GitHub
- URL: https://github.com/indoqa/solr-spring-client
- Owner: Indoqa
- License: apache-2.0
- Created: 2015-05-12T14:43:22.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T07:38:33.000Z (over 1 year ago)
- Last Synced: 2024-04-09T12:01:39.940Z (about 1 year ago)
- Topics: indoqa-library, solr, solr-client
- Language: Java
- Homepage:
- Size: 104 KB
- Stars: 3
- Watchers: 10
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Indoqa Solr Spring Client
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
```xml
com.indoqa.solr
solr-spring-client
```* Download source
* run "maven clean install"## Configuration
### Initialize the SolrClientFactory for tests with this snippet
```javaSolrClientFactory solrClientFactory = new SolrClientFactory();
solrClientFactory.setUrl("file:///tmp/solr-spring-server/embedded-test-core");
solrClientFactory.setEmbeddedSolrConfigurationDir("./src/test/resources/solr/test-core");
solrClientFactory.initialize();SolrServer solrServer = solrClientFactory.getObject();
QueryResponse response = solrServer.query(new SolrQuery("*:*"));
...
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
```java
SolrClientFactory solrClientFactory = new SolrClientFactory();
solrClientFactory.setUrl("http://localhost:8983/test-core");
solrClientFactory.initialize();
```### To communicate with a SolrCloud cluster use this snippet
```java
SolrClientFactory solrClientFactory = new SolrClientFactory();
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
```xml
```