Skip to content

potatobeansco/go-solr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

solr

solr library provides a simple Apache Solr HTTP client to interact with collections in a Solr instance. The library does not care whether Solr is deployed as a standalone instance or SolrCloud. This library does not provide any feature to interact with Solr data in ZooKeeper.

It provides basic functionalities such as selections and document updates.

This library is now published as open source for anyone to use, including former PotatoBeans clients.

Usage

The go-solr module adds a way to make HTTP calls to Solr with some types already provided as structs. With this client, currently select and update (in-place and direct) are supported. Deleting documents can be done using the Solr update operation.

Solr collections by default have select and update endpoints. Select is used to retrieve data while update is used to do updates such as insert, update, and delete. This module provides functionalities for all of them without advanced functionalities such as collection management (backups, replication, and so on).

Currently only JSON payload is supported (wt=json parameter is supplied automatically).

package main

import (
	"context"
	"encoding/json"
	"github.com/potatobeansco/go-solr"
)

func main() {
	// The default Solr instances are usually configured under the /solr base URL in port 8983
	c := solr.NewClient("http://127.0.0.1:8983/solr")

	resp, err := c.SelectCtx(context.TODO(), &solr.Params{
		Q    : "*:*",
		Start: 1,
		Rows : 100,
    })
	if err != nil {
		fmt.Printf("unable to make connection to Solr: %s\n", err.Error())
		os.Exit(1)
		return
    }
	
	// Parse the returned docs as JSON
	payload := make(map[string]interface{})
	err = json.Unmarshal(&payload, resp.Body.Docs)
}

More functionalities will be supported in the future.

About

PotatoBeans standard Apache Solr client library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages