Documentation
¶
Index ¶
- Constants
- func BytesToJSON(b *[]byte) (*interface{}, error)
- func EncodeURLParamMap(m *URLParamMap) string
- func GetCoreStatus(host string, port int, context, coreName string) (map[string]interface{}, error)
- func HTTPGeWithHeaders(httpUrl string, headers [][]string) ([]byte, error)
- 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 ListCores(host string, port int, context string) ([]string, error)
- func SolrSelectString(c *Connection, q string, handlerName string) string
- func SolrUpdateString(c *Connection, commit bool) string
- type BasicField
- 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) GetCoreFile(fileName string) ([]byte, error)
- func (c *Connection) GetCoreStatus(coreName string) (map[string]interface{}, error)
- func (c *Connection) GetSchemaDefinition() (*Schema, error)
- func (c *Connection) GetSolrConfig() (*SolrConfig, error)
- func (c *Connection) ListCores() ([]string, 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 DynamicField
- type ErrorResponse
- type Facet
- type FacetCount
- type Field
- type FieldType
- type Query
- type Schema
- type SelectResponse
- type SolrConfig
- type URLParamMap
- type UpdateResponse
Constants ¶
const ( ConfigFile = "solrconfig.xml" SchemaFile = "schema.xml" ClassicIndexSchemaFactory = "ClassicIndexSchemaFactory" )
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 GetCoreStatus ¶
* GetCoreStatus return core detail status
func HTTPGeWithHeaders ¶
* Performs a GET request to the given url, and related headers * Returns a []byte containing the response body
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 BasicField ¶
type BasicField struct { Name string `xml:"name,attr"` Type string `xml:"type,attr"` Indexed bool `xml:"indexed,attr"` Stored bool `xml:"stored,attr"` MultiValued bool `xml:"multiValued,attr"` }
* BasicFiled as parent of Field & DynamicField
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 InitWithCtx ¶
func InitWithCtx(host string, port int, context, 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}/{context}/{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) GetCoreFile ¶
func (c *Connection) GetCoreFile(fileName string) ([]byte, error)
* GetCoreFile get solr config file
func (*Connection) GetCoreStatus ¶
func (c *Connection) GetCoreStatus(coreName string) (map[string]interface{}, error)
* GetCoreStatus return core detail status
func (*Connection) GetSchemaDefinition ¶
func (c *Connection) GetSchemaDefinition() (*Schema, error)
* GetSchemaDefinition get schema field defintion
func (*Connection) GetSolrConfig ¶
func (c *Connection) GetSolrConfig() (*SolrConfig, error)
* GetSolrConfig get and parse solrconfig.xml
func (*Connection) ListCores ¶
func (c *Connection) ListCores() ([]string, error)
* ListCores list all cores in this solr server context
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 Field ¶
type Field struct { BasicField Default string `xml:"default,attr"` OmitNorms bool `xml:"omitNorms,attr"` TermVectors bool `xml:"termVectors,attr"` TermPositions bool `xml:"termPositions,attr"` TermOffsets bool `xml:"termOffsets,attr"` DocValues bool `xml:"docValues,attr"` }
* Filed from schema.xml, did NOT cover all attributes
type FieldType ¶
type FieldType struct { Name string `xml:"name,attr"` Class string `xml:"class,attr"` Indexed bool `xml:"indexed,attr"` SortMissingLast bool `xml:"sortMissingLast,attr"` PrecisionStep int32 `xml:"precisionStep,attr"` PositionIncrementGap int32 `xml:"positionIncrementGap,attr"` AutoGeneratePhraseQueries bool `xml:"autoGeneratePhraseQueries,attr"` OmitNorms bool `xml:"omitNorms,attr"` Stored bool `xml:"stored,attr"` MultiValued bool `xml:"multiValued,attr"` DocValues bool `xml:"docValues,attr"` }
* FieldType from schema.xml, did NOT cover all attributes
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 Schema ¶
type Schema struct { Field []Field `xml:"field"` DynamicField []DynamicField `xml:"dynamicField"` FieldType []FieldType `xml:"fieldType"` }
* Schema from schema.xml
func (*Schema) FindFieldType ¶
* FindFieldType, Find related Field Type according name
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 SolrConfig ¶
type SolrConfig struct { XMLName xml.Name `xml:"config"` LuceneMatchVersion string `xml:"luceneMatchVersion"` CodecFactory struct { Class string `xml:"class,attr"` } `xml:"codecFactory"` SchemaFactory struct { Class string `xml:"class,attr"` } `xml:"schemaFactory"` }
* SolrConfig from solrconfig.xml
type UpdateResponse ¶
type UpdateResponse struct {
Success bool
}
func (UpdateResponse) String ¶
func (r UpdateResponse) String() string