solr

package module
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DisMax is a valid defType to specify the dismax query parser.
	DisMax = "dismax"

	// ExtendedDisMax is a valid defType to specify the extended dismax query parser.
	ExtendedDisMax = "edismax"
)

Variables

View Source
var (
	// ErrCollectionNotFound is returned by any operation if the target
	// collection isn't found.
	ErrCollectionNotFound = errors.New(`solr: the specified collection was not found`)
)

Functions

func Index

func Index(collection string, docs documents) error

Index will send a batch of documents to Solr for upsertion.

func Init

func Init(opts *Options) error

Init will initialize the Solr client. If an error is returned, Solr isn't available or configured properly.

func Ping

func Ping() error

Ping will check if Solr is running. If there's any issue, a non-nil error will be returned.

Types

type Options

type Options struct {
	Host       string
	Port       string
	Collection string
	Debug      bool
}

Options are configuration settings for Solr.

type Query added in v1.0.2

type Query struct {
	Q       string
	Op      string   /* q.op: AND or OR (default: AND) */
	DefType string   /* defType: dismax or lucense */
	Qf      string   /* query fields for dismax */
	Bf      string   /* boost function to influence matches */
	Bq      string   /* boost query allows you to boost certain queries */
	Fq      []string /* filter queries will filter out by a field */
	Boost   string   /* boost field list parameter */
	Mm      string   /* minimum match */
	Filter  string   /* filter the fields returned by Solr */
	Sort    string   /* sort the documents returned by Solr */
	Start   int      /* which document to start from */
	Rows    int      /* the number of documents per-page */
}

Query represents a search query.

type Response added in v1.0.2

type Response struct {
	ResponseHeader struct {
		Status int `json:"status"`
		QTime  int `json:"QTime"`
		Params struct {
			Q   string `json:"q"`
			QOp string `json:"q.op"`
			WT  string `json:"wt"`
		} `json:"params"`
	} `json:"responseHeader"`

	Response struct {
		NumFound int `json:"numFound"`
		Start    int `json:"start"`
		Docs     []struct {
			UUID string `json:"uuid"`
		} `json:"docs"`
	} `json:"response"`

	Status string `json:"status"`
}

Response is the raw Solr search response. The format matches the JSON response format for Solr. This is a bit clunky to work with.

type Result added in v1.0.2

type Result struct {
	Response
	NumFound int      /* total documents found for the query */
	Query    *Query   /* metadata regarding the query that resulted in this */
	UUIDs    []string /* documents found for the latest query */
}

Result wraps the raw Solr response and provides simplified access to the original query and document uuids.

func Search(collection string, query *Query) (*Result, error)

Search will query Solr and find profiles for a query. Returns the UUIDs for the matched documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL