Skip to content

oleewere/go-solr-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

455cc8c · Apr 25, 2019

History

71 Commits
Dec 8, 2018
Apr 25, 2019
Jan 9, 2019
Dec 8, 2018
Dec 8, 2018
Jul 8, 2018
Dec 8, 2018
Feb 15, 2018
Dec 8, 2018
Apr 25, 2019
Jan 9, 2019
Jan 9, 2019
Dec 7, 2018
Jul 25, 2018

Repository files navigation

Go Solr Client

Build Status Go Report Card license

Install

go get -u github.com/oleewere/solr-client

Usage

import (
	"github.com/oleewere/go-solr-client/solr"
)

func main() {
	securityConfig := SecurityConfig{}
	if kerberosEnabled {
		securityConfig = InitSecurityConfig(krb5Path, keytabPath, principal, realm)
	}
	
	// ...
	
	solrUrl := "http://localhost:8886"
	solrCollection := "mycollection"
	solrConext := "/solr"
	tlsConfig := TLSConfig{}
	
	// ...
	
	solrConfig := SolrConfig{solrUrl, solrCollection, &securityConfig, solrContext,
		tlsConfig, false, solrConnectionTimeout}
	// ...
	
	solrClient, err := NewSolrClient(solrConfig)
	// Create a query - example
	solrQuery := solr.CreateSolrQuery()
	solrQuery.Query("*:*")
	// you can set params one-by-one with solrQuery.AddParam or solrQuery.SetParam etc.
	solrClient.Query(&solrQuery)
	
	// Update docs - example 
	solrDoc1 := make(map[string]interface{})
	solrDoc1["id"] = uuid.NewV4().String()
	// ...
	solrDoc2 := make(map[string]interface{})
	solrDoc2["id"] = uuid.NewV4().String()
	// ...
	solrDocs := make([]interface{}, 0)
	solrDocs = append(solrDocs, solrDoc1)
	solrDocs = append(solrDocs, solrDoc2)
	// ...
	solrClient.Update(solrDocs, nil, true)
}

Developement

make build

Key features

  • Basic auth support
  • Kerberos support