solrutil

package
v0.1.366 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package solrutil implements helpers to access a SOLR index. WIP.

Index

Constants

View Source
const DefaultFacetLimit = 100000

DefaultFacetLimit for fetching collections (there might be tens of thousands).

Variables

This section is empty.

Functions

func FindLiveSolrServer added in v0.1.248

func FindLiveSolrServer(spanConfigFile string) (string, error)

FindLiveSolrServer returns the current live SOLR URL. XXX: Maybe drop.

func FindNonliveSolrServer added in v0.1.248

func FindNonliveSolrServer(spanConfigFile string) (string, error)

FindNonliveSolrServer tries to find the URL of the current testing solr. There might be different way to retrieve a useable URL (configuration, probes). For now we use a separate configuration file, that contains the URL to the nginx snippet. XXX: Maybe make findSolrServer public and skip the special methods.

func PrependHTTP added in v0.1.252

func PrependHTTP(s string) string

PrependHTTP prepends http, if necessary.

Types

type FacetMap

type FacetMap map[string]int

FacetMap maps a facet value to its frequency. Solr uses pairs put into a list, which is a bit awkward to work with.

func (FacetMap) AllowedKeys

func (f FacetMap) AllowedKeys(allowed ...string) error

AllowedKeys returns an error if facets values contain non-zero values that are not explicitly allowed. Used for reviews.

func (FacetMap) EqualSizeNonZero

func (f FacetMap) EqualSizeNonZero(keys ...string) error

EqualSizeNonZero checks if frequencies of the given keys are the same and non-zero. Used for reviews.

func (FacetMap) Nonzero added in v0.1.252

func (fm FacetMap) Nonzero() FacetMap

Nonzero returns a FacetMap, which contains only non-zero frequencies.

type Index

type Index struct {
	Server     string
	FacetLimit int
}

Index allows to send various queries to SOLR.

func (Index) AllowedKeys

func (index Index) AllowedKeys(query, field string, values ...string) error

AllowedKeys checks for a query and facet field, whether the values contain only allowed values. Used for reviews.

func (Index) EqualSizeNonZero

func (index Index) EqualSizeNonZero(query, field string, values ...string) error

EqualSizeNonZero checks, if given facet field values have the same size. Used for reviews.

func (Index) EqualSizeTotal

func (index Index) EqualSizeTotal(query, field string, values ...string) error

EqualSizeTotal checks, if given facet field values have the same size as the total number of records. Used for reviews.

func (Index) FacetKeys

func (index Index) FacetKeys(query, field string) (result []string, err error)

FacetKeys returns the values of a facet as a string slice.

func (Index) FacetKeysFunc

func (index Index) FacetKeysFunc(query, field string, f func(string, int) bool) (result []string, err error)

FacetKeysFunc returns all facet keys, that pass a filter, given as function of facet value and frequency.

func (index Index) FacetLink(query, facetField string) string

FacetLink constructs a link to a JSON response.

func (Index) FacetQuery added in v0.1.252

func (index Index) FacetQuery(query, facetField string) (resp *SelectResponse, err error)

FacetQuery runs a facet query.

func (Index) Institutions

func (index Index) Institutions() (result []string, err error)

Institutions returns a list of International Standard Identifier for Libraries and Related Organisations (ISIL), ISO 15511 identifiers.

func (Index) MinCount

func (index Index) MinCount(query, field, value string, minCount int) error

MinCount fails, if the number of records matching a value undercuts a given size. Used for reviews.

func (Index) MinRatioPct

func (index Index) MinRatioPct(query, field, value string, minRatioPct float64) error

MinRatioPct fails, if the number of records matching a value undercuts a given ratio of all records matching the query. The ratio ranges from 0 to 100. Used for reviews.

func (Index) NumFound

func (index Index) NumFound(query string) (int64, error)

NumFound returns the size of the result set for a query.

func (Index) RandomCollection added in v0.1.252

func (index Index) RandomCollection(sid string) (string, error)

RandomCollection returns a random collection for a source identifier.

func (Index) RandomSource added in v0.1.252

func (index Index) RandomSource() (string, error)

RandomSource returns a random source identifier.

func (Index) Select

func (index Index) Select(vs url.Values) (*SelectResponse, error)

Select allows to pass any parameter to select.

func (Index) SelectQuery added in v0.1.252

func (index Index) SelectQuery(query string) (resp *SelectResponse, err error)

SelectQuery runs a select query.

func (Index) SourceCollections

func (index Index) SourceCollections(sid string) (result []string, err error)

SourceCollections returns the collections for a given source identifier.

func (Index) SourceIdentifiers

func (index Index) SourceIdentifiers() (result []string, err error)

SourceIdentifiers returns a list of source identifiers.

type SelectResponse

type SelectResponse struct {
	FacetCounts struct {
		FacetDates struct {
		} `json:"facet_dates"`
		// FacetFields must be parsed by the user. It will contain a map from
		// field name to facet value and counts. Example: {"name": ["Ben",
		// 100, "Celine", 58, ...]}.
		FacetFields   json.RawMessage `json:"facet_fields"`
		FacetHeatmaps struct {
		} `json:"facet_heatmaps"`
		FacetIntervals struct {
		} `json:"facet_intervals"`
		FacetQueries struct {
		} `json:"facet_queries"`
		FacetRanges struct {
		} `json:"facet_ranges"`
	} `json:"facet_counts"`
	Response struct {
		Docs     []json.RawMessage `json:"docs"`
		NumFound int64             `json:"numFound"`
		Start    int64             `json:"start"`
	} `json:"response"`
	ResponseHeader struct {
		Params struct {
			Facet      string `json:"facet"`
			Facetfield string `json:"facet.field"`
			Indent     string `json:"indent"`
			Q          string `json:"q"`
			Rows       string `json:"rows"`
			Wt         string `json:"wt"`
		} `json:"params"`
		QTime  int64
		Status int64 `json:"status"`
	} `json:"responseHeader"`
}

SelectResponse wraps search and facet responses.

func (SelectResponse) Facets added in v0.1.252

func (sr SelectResponse) Facets() (FacetMap, error)

Facets unwraps the facet_fields list into a FacetMap.

Jump to

Keyboard shortcuts

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