Go Solr Client
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)
solrQuery := solr.CreateSolrQuery()
solrQuery.Query("*:*")
solrClient.Query(&solrQuery)
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