项目作者: oleewere

项目描述 :
Golang Solr client with Kerberos support
高级语言: Go
项目地址: git://github.com/oleewere/go-solr-client.git
创建时间: 2018-02-09T23:44:19Z
项目社区:https://github.com/oleewere/go-solr-client

开源协议:Apache License 2.0

下载


Go Solr Client

Build Status
Go Report Card
license

Install

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

Usage

  1. import (
  2. "github.com/oleewere/go-solr-client/solr"
  3. )
  4. func main() {
  5. securityConfig := SecurityConfig{}
  6. if kerberosEnabled {
  7. securityConfig = InitSecurityConfig(krb5Path, keytabPath, principal, realm)
  8. }
  9. // ...
  10. solrUrl := "http://localhost:8886"
  11. solrCollection := "mycollection"
  12. solrConext := "/solr"
  13. tlsConfig := TLSConfig{}
  14. // ...
  15. solrConfig := SolrConfig{solrUrl, solrCollection, &securityConfig, solrContext,
  16. tlsConfig, false, solrConnectionTimeout}
  17. // ...
  18. solrClient, err := NewSolrClient(solrConfig)
  19. // Create a query - example
  20. solrQuery := solr.CreateSolrQuery()
  21. solrQuery.Query("*:*")
  22. // you can set params one-by-one with solrQuery.AddParam or solrQuery.SetParam etc.
  23. solrClient.Query(&solrQuery)
  24. // Update docs - example
  25. solrDoc1 := make(map[string]interface{})
  26. solrDoc1["id"] = uuid.NewV4().String()
  27. // ...
  28. solrDoc2 := make(map[string]interface{})
  29. solrDoc2["id"] = uuid.NewV4().String()
  30. // ...
  31. solrDocs := make([]interface{}, 0)
  32. solrDocs = append(solrDocs, solrDoc1)
  33. solrDocs = append(solrDocs, solrDoc2)
  34. // ...
  35. solrClient.Update(solrDocs, nil, true)
  36. }

Developement

  1. make build

Key features

  • Basic auth support
  • Kerberos support