Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

at15/go-solr

Repository files navigation

go-solr

GoDoc Build Status codebeat badge

Solr client in golang

Usage

  • install the cli using go get -u github.com/at15/go-solr/cmd/solrgo, it can create core and index json document
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/at15/go-solr/solr"
)

const coreName = "job"

func main() {
    c := solr.Config{}
    solrClient, err := solr.NewClient(c)
    if err != nil {
        log.Fatal(err)
        return
    }
    if err := solrClient.IsUp(context.Background()); err != nil {
        log.Fatalf("Solr is not up %v", err)
        return
    }
    log.Println("Solr is up")
    solrClient.UseCore(coreName)
    if status, err := solrClient.DefaultCore.Status(context.Background(), false); err != nil {
        log.Fatalf("Check core status failed %v", err)
        return
    } else {
        log.Printf("Got status for core %s %v\n", coreName, status)
    }
}

Features

  • standalone command line util (single binary)
  • query builder
  • auto convert struct to JSON when ingest document

Not implemented

Roadmap

  • using managed schema
    • generate schema xml based on golang struct (w/o?) annotation
    • support schema less
  • query using JSON API
  • v2 API
  • collect metrics about upstream
  • client side load balancing

Alternatives