Documentation ¶
Index ¶
- func BytesToJSON(b *[]byte) (*interface{}, error)
- func EncodeURLParamMap(m *URLParamMap) string
- func HTTPGet(httpUrl string) ([]byte, error)
- func HTTPPost(url string, headers [][]string, payload *[]byte) ([]byte, error)
- func JSONToBytes(m map[string]interface{}) (*[]byte, error)
- func SolrSelectString(c *Connection, q string, handlerName string) string
- func SolrUpdateString(c *Connection, commit bool) string
- type Connection
- func (c *Connection) CustomSelect(q *Query, handlerName string) (*SelectResponse, error)
- func (c *Connection) CustomSelectRaw(q string, handlerName string) (*SelectResponse, error)
- func (c *Connection) Select(q *Query) (*SelectResponse, error)
- func (c *Connection) SelectRaw(q string) (*SelectResponse, error)
- func (c *Connection) Update(m map[string]interface{}, commit bool) (*UpdateResponse, error)
- type Document
- type DocumentCollection
- type ErrorResponse
- type Facet
- type FacetCount
- type Query
- type SelectResponse
- type URLParamMap
- type UpdateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToJSON ¶
* Decodes a json formatted []byte into an interface{} type
func EncodeURLParamMap ¶
func EncodeURLParamMap(m *URLParamMap) string
* Returns a URLEncoded version of a Param Map * E.g., ParamMap[foo:bar omg:wtf] => "foo=bar&omg=wtf" * TODO: This isn't exactly safe and there's probably a library pkg to do this already...
func HTTPGet ¶
* Performs a GET request to the given url * Returns a []byte containing the response body
func HTTPPost ¶
* Performs a HTTP Post request. Takes: * * A url * * Headers, in the format [][]string{} (e.g., [[key, val], [key, val], ...]) * * A payload (post request body) which can be nil * * Returns the body of the response and an error if necessary
func JSONToBytes ¶
* Encodes a map[string]interface{} to bytes and returns * a pointer to said bytes
func SolrSelectString ¶
func SolrSelectString(c *Connection, q string, handlerName string) string
* Generates a Solr query string from a connection, query string and handler name
func SolrUpdateString ¶
func SolrUpdateString(c *Connection, commit bool) string
* Generates a Solr update query string. Adds ?commit=true * if commit arg is true.
Types ¶
type Connection ¶
* Represents a "connection"; actually just a host and port * (and probably at some point a Solr Core name)
func Init ¶
func Init(host string, port int, core string) (*Connection, error)
* Inits a new Connection to a Solr instance * Note: this doesn't actually hold a connection, its just * a container for the URL. * This creates a URL with the pattern http://{host}:{port}/solr/{core} * If you want to create a connection with another pattern just create * the struct directly i.e. conn := &Connection{myCustomURL}.
func (*Connection) CustomSelect ¶
func (c *Connection) CustomSelect(q *Query, handlerName string) (*SelectResponse, error)
* Performs a Select query given a Query and handlerName
func (*Connection) CustomSelectRaw ¶
func (c *Connection) CustomSelectRaw(q string, handlerName string) (*SelectResponse, error)
* Performs a raw Select query given a raw query string and handlerName
func (*Connection) Select ¶
func (c *Connection) Select(q *Query) (*SelectResponse, error)
* Performs a Select query given a Query
func (*Connection) SelectRaw ¶
func (c *Connection) SelectRaw(q string) (*SelectResponse, error)
* Performs a raw Select query given a raw query string
func (*Connection) Update ¶
func (c *Connection) Update(m map[string]interface{}, commit bool) (*UpdateResponse, error)
* Performs a Solr Update query against a given update document * specified in a map[string]interface{} type * NOTE: Requires JSON updates to be enabled, see; * http://wiki.apache.org/solr/UpdateJSON * FUTURE: Will ask for solr version details in Connection and * act appropriately
type Document ¶
type Document struct {
Fields map[string]interface{}
}
* Represents a Solr document, as returned by Select queries
type DocumentCollection ¶
type DocumentCollection struct { Facets []Facet Collection []Document NumFacets int // convenience... NumFound int Start int }
* Represents a collection of solr documents * and various other metrics
func (*DocumentCollection) Get ¶
func (d *DocumentCollection) Get(i int) *Document
* DocumentCollection.Get() returns the document in the collection * at position i
func (*DocumentCollection) Len ¶
func (d *DocumentCollection) Len() int
* DocumentCollection.Len() returns the amount of documents * in the collection
type ErrorResponse ¶
* Represents an error from Solr
func SolrErrorResponse ¶
func SolrErrorResponse(m map[string]interface{}) (bool, *ErrorResponse)
* Determines whether a decoded response from Solr * is an error response or not. Returns a bool (true if error) * and an ErrorResponse (if the response is an error response) * otherwise nil
func (ErrorResponse) String ¶
func (r ErrorResponse) String() string
type Facet ¶
type Facet struct { Name string // accepts_4x4s Counts []FacetCount // a set of values }
* Represents a Facet with a name and count
type FacetCount ¶
* Represents a FacetCount for a Facet
type Query ¶
type Query struct { Params URLParamMap Rows int Start int Sort string DefType string Debug bool OmitHeader bool }
* Query represents a query with various params
type SelectResponse ¶
type SelectResponse struct { Results *DocumentCollection Status int QTime int }
* Represents a Solr response
func BuildResponse ¶
func BuildResponse(j *interface{}) (*SelectResponse, error)
* Takes a JSON formatted Solr response (interface{}, not []byte) * And returns a *Response
func SelectResponseFromHTTPResponse ¶
func SelectResponseFromHTTPResponse(b []byte) (*SelectResponse, error)
* Decodes a HTTP (Solr) response and returns a Response
func (SelectResponse) String ¶
func (r SelectResponse) String() string
type UpdateResponse ¶
type UpdateResponse struct {
Success bool
}
func (UpdateResponse) String ¶
func (r UpdateResponse) String() string