https://github.com/sendgrid/go-solr
solr go client from sendgrid, zookeeper aware, incorporates retries
https://github.com/sendgrid/go-solr
golang golang-library mc solrcloud zookeeper
Last synced: 7 months ago
JSON representation
solr go client from sendgrid, zookeeper aware, incorporates retries
- Host: GitHub
- URL: https://github.com/sendgrid/go-solr
- Owner: sendgrid
- License: mit
- Created: 2017-04-06T18:32:06.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-04-26T15:02:10.000Z (almost 7 years ago)
- Last Synced: 2025-08-14T12:52:01.475Z (7 months ago)
- Topics: golang, golang-library, mc, solrcloud, zookeeper
- Language: Go
- Homepage:
- Size: 3.48 MB
- Stars: 39
- Watchers: 129
- Forks: 26
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://travis-ci.org/sendgrid/go-solr)
[](https://goreportcard.com/report/github.com/sendgrid/go-solr)
[](https://godoc.org/github.com/sendgrid/go-solr)
[](./LICENSE)
[](https://cla.sendgrid.com/sendgrid/go-solr)
[](https://github.com/sendgrid/go-solr/graphs/contributors)
# go-solr
solr go client from Sendgrid
## Usage
To start the client
```
solrzk := solr.NewSolrZK(...)
solrzk.Listen()
solrhttp := solr.NewSolrHttp(solrzk)
solrClient := solr.NewSolrHttpRetrier(solrhttp)
```
The Read and Update methods take a node list use the SolrLocator interface to return a node list
```
locator := solr.GetSolrLocator(solr.NewSolrZK(...))
type SolrLocator interface {
GetLeaders(docID string) ([]string, error)
GetReplicaUris() ([]string, error)
GetReplicasFromRoute(route string) ([]string, error)
GetLeadersAndReplicas(docID string) ([]string, error)
}
```
To make requests
```
solrClient.Select(locator.GetReplicasFromRoute("shard!"),solr.FilterQuery("myfield:test"),solr.Route("shardkey!"))
```
To make updates
```
solrClient.Update(locator.GetLeadersAndReplicas("{anydocidtoroute}"),collectionName,callsSolrJsonDocs, docsMap)
```
## Tests on solr
1. ```docker-compose up ```
2. ```docker-compose run gotests bash ```
3. ```go test ```
4. ```go run ./cmd/solrRunner.go 1000 ```
## Tests with cluster of 3 solrs
1. ```docker-compose -p cluster -f docker-compose.cluster.yml up ```
2. ```docker-compose -p cluster run gotests bash ```
3. ```go test ```
4. ```go run ./cmd/solrRunner.go 1000 ```
## License
[The MIT License (MIT)](LICENSE)