$ go get github.com/stevenferrer/solr-go
import (
"github.com/stevenferrer/solr-go"
)
...
// Create a client
baseURL := "http://solr.example.com"
client := solr.NewJSONClient(baseURL)
// Create a query
query := solr.NewQuery(solr.NewDisMaxQueryParser().
Query("'solr rocks'").BuildParser()).
Queries(solr.M{
"query_filters": []solr.M{
{
"#size_tag": solr.M{
"field": solr.M{
"f": "size",
"query": "XL",
},
},
},
{
"#color_tag": solr.M{
"field": solr.M{
"f": "color",
"query": "Red",
},
},
},
},
}).
Facets(
solr.NewTermsFacet("categories").
Field("cat").Limit(10),
solr.NewQueryFacet("high_popularity").
Query("popularity:[8 TO 10]"),
).
Sort("score").
Offset(1).
Limit(10).
Filters("inStock:true").
Fields("name", "price")
// Send the query
queryResponse, err := client.Query(context.Background(), "techproducts", query)
See integration test for a more complete example.
- Collections API - Create and delete collection.
- Core Admin API - Create, delete and check core status.
- Query API - Query via the JSON request API.
- Facet API - Terms and query facet.
- Update API - JSON formatted index updates.
- Schema API - Modify schema fields, dynamic fields, copy fields and field types.
- Config API - Modify config properties and update components.
- Suggester API - Auto-suggest/type-ahead via suggester component.
- Basic auth support - Interacting with a Solr server that uses the basic authentication plugin.
Keep in mind that this library is still evolving and will likely have some breaking changes until v1.0. We will try our best to keep the breaking changes minimal.
You can support the project in the following ways:
- Give it a star, it's free!
- Write some tutorials
- Use it your projects
Please feel free to improve this project by opening an issue or by making a pull-request.
MIT