Giter Site home page Giter Site logo

solr's Introduction

solr

A Solr client written in Go

Designed for Solr 8.5 (Should support earlier versions as well)

Provides clients for Solr's Request API, Schema API & Core Admin API

Currently supports only JSON and basic CRUDL actions.

Installation

go get -u github.com/mecenat/solr

Usage

To create a new solr Client you need first to create a Connection. To create a Connection you need the host location (e.g. http://localhost:8983), the core name, and a http client (e.g. http.DefaultClient). Sending your own client could be useful when you need to wrap the client with another service, for example if you want to use AWS's X-Ray service to trace your API's calls.

When using a single server:

package main

import "github.com/mecenat/solr"

func main() {
	conn, err := solr.NewConnection("host", "core", http.DefaultClient)
	if err != nil {
				...
	}
	slr, err := solr.NewSingleClient(conn)
	if err != nil {
	      ...
	}

When using a the Primary-Replica paradigm:

package main

import "github.com/mecenat/solr"

func main() {
	primaryConn, err := solr.NewConnection("primaryHost", "core", http.DefaultClient)
	if err != nil {
				...
	}
	replicaConn, err := solr.NewConnection("replicaHost", "core", http.DefaultClient)
	if err != nil {
				...
	}
	slr, err := solr.NewPrimaryReplicaClient(primaryConn, replicaConn)
	if err != nil {
	      ...
	}

Aside from the normal Connection you can you a RetryableConnection which implements Hashicorp's retryable HttpClient specifying the max timeout and provide that connection to the clients.

package main

import "github.com/mecenat/solr"

func main() {
	retConn, err := solr.NewRetryableConnection("host", "core", http.DefaultClient, 500*time.Millisecond)
	if err != nil {
				...
	}
	slr, err := solr.NewSingleClient(retConn)
	if err != nil {
	      ...
	}

To access Solr's Core Admin API you need to create a separate client as follows:

package main

import "github.com/mecenat/solr"

func main() {
	ctx := context.Background()
	ca, err := solr.NewCoreAdmin(ctx, "host", http.DefaultClient)
	if err != nil {
				...
	}

To access Solr's Schema API you also need a separate client as follows:

package main

import "github.com/mecenat/solr"

func main() {
	ctx := context.Background()
	sa, err := solr.NewSchemaAPI(ctx, "host", "core", http.DefaultClient)
	if err != nil {
				...
	}

License

MIT

solr's People

Contributors

kostaskoukouvis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

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.