Skip to content

stevenferrer/solr-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4372215 · Feb 12, 2025
Mar 11, 2023
Mar 30, 2021
May 15, 2020
Apr 1, 2020
Mar 30, 2021
Feb 12, 2025
Mar 30, 2021
Mar 30, 2021
Nov 3, 2021
Feb 9, 2021
Nov 3, 2021
Mar 30, 2021
Nov 3, 2021
Mar 11, 2023
Mar 11, 2023
Mar 17, 2021
Nov 3, 2021
Mar 11, 2023
Mar 11, 2023
Nov 3, 2021
Mar 11, 2023
Mar 11, 2023
Feb 15, 2021
Nov 3, 2021
Feb 12, 2025
Feb 13, 2021
Nov 3, 2021
Feb 12, 2025
Mar 11, 2023
Nov 3, 2021
Mar 30, 2021
Nov 3, 2021
May 8, 2024
Feb 13, 2021
Nov 3, 2021

Repository files navigation

Solr-Go

Github Actions Coverage Status Go Report Card GoDoc

A Solr client for Go.

Installation

$ go get github.com/stevenferrer/solr-go

Example

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]"),
    ).
    Params(solr.M{
        "spellcheck.q": "solr rocks",
    }).
    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