Skip to content

occmundial/search-solr-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solr-Go

Github Actions Coverage Status Go Report Card GoDoc

A Solr client for Go.

Installation

$ go get github.com/occmundial/search-solr-go

Example

import (
    "github.com/occmundial/search-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.

Supported APIs

Other features

  • Basic auth support - Interacting with a Solr server that uses the basic authentication plugin.

Projects using it

A (minor) word of caution

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.

Supporting the project

You can support the project in the following ways:

  • Give it a star, it's free!
  • Write some tutorials
  • Use it your projects

Contributing

Please feel free to improve this project by opening an issue or by making a pull-request.

License

MIT

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.6%
  • Makefile 1.4%