Giter Club home page Giter Club logo

solr-spring-client's Introduction

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

    SolrClientFactory 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

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

To communicate with a SolrCloud cluster use this snippet

   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

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

solr-spring-client's People

Contributors

aeibner avatar reinhard avatar stevendolg avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sneha1702

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.