solrutil

package
v0.1.242 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const DefaultFacetLimit = 100000

Variables

This section is empty.

Functions

This section is empty.

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

AllowedOnly returns an error if facets values contain non-zero values that are not explicitly allowed.

func (FacetMap) EqualSizeNonZero

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

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

type FacetResponse

type FacetResponse struct {
	FacetCounts struct {
		FacetDates struct {
		} `json:"facet_dates"`
		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     []interface{} `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"`
}

FacetResponse wraps a facet response, adjusted from JSONGen output.

func (FacetResponse) Facets

func (fr FacetResponse) Facets() (FacetMap, error)

Facets unwraps the facet_fields list into a FacetMap.

type Index

type Index struct {
	Server     string
	FacetLimit int
}

Index allows to send various queries to SOLR.

func (Index) AllowedKeys

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

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

func (Index) EqualSizeNonZero

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

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

func (Index) EqualSizeTotal

func (ix 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.

func (Index) Facet

func (ix Index) Facet(query, facetField string) (r *FacetResponse, err error)

Facet runs a facet query.

func (Index) FacetKeys

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

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

func (Index) FacetKeysFunc

func (ix 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 (ix Index) FacetLink(query, facetField string) string

FacetLink constructs a link to a JSON response.

func (Index) Institutions

func (ix 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 (ix Index) MinCount(query, field, value string, minCount int) error

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

func (Index) MinRatioPct

func (ix 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.

func (Index) NumFound

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

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

func (Index) Select

func (ix Index) Select(query string) (r *SelectResponse, err error)

Select runs a select query.

func (ix Index) SelectLink(query string) string

SelectLink constructs a link to a JSON response.

func (Index) SourceCollections

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

SourceCollections returns the collections for a given source identifier.

func (Index) SourceIdentifiers

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

SourceIdentifiers returns a list of source identifiers.

type SelectResponse

type SelectResponse struct {
	Response struct {
		Docs     []interface{} `json:"docs"`
		NumFound int64         `json:"numFound"`
		Start    int64         `json:"start"`
	} `json:"response"`
	ResponseHeader struct {
		Params struct {
			Indent string `json:"indent"`
			Q      string `json:"q"`
			Wt     string `json:"wt"`
		} `json:"params"`
		QTime  int64
		Status int64 `json:"status"`
	} `json:"responseHeader"`
}

SelectResponse wraps a select response, adjusted from JSONGen.

Jump to

Keyboard shortcuts

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