Documentation
¶
Overview ¶
Package solrutil implements helpers to access a SOLR index. WIP.
Index ¶
- Constants
- func FindLiveSolrServer(spanConfigFile string) (string, error)
- func FindNonliveSolrServer(spanConfigFile string) (string, error)
- type FacetMap
- type FacetResponse
- type Index
- func (ix Index) AllowedKeys(query, field string, values ...string) error
- func (ix Index) EqualSizeNonZero(query, field string, values ...string) error
- func (ix Index) EqualSizeTotal(query, field string, values ...string) error
- func (ix Index) Facet(query, facetField string) (r *FacetResponse, err error)
- func (ix Index) FacetKeys(query, field string) (result []string, err error)
- func (ix Index) FacetKeysFunc(query, field string, f func(string, int) bool) (result []string, err error)
- func (ix Index) FacetLink(query, facetField string) string
- func (ix Index) Institutions() (result []string, err error)
- func (ix Index) MinCount(query, field, value string, minCount int) error
- func (ix Index) MinRatioPct(query, field, value string, minRatioPct float64) error
- func (ix Index) NumFound(query string) (int64, error)
- func (ix Index) Select(query string) (r *SelectResponse, err error)
- func (ix Index) SelectLink(query string) string
- func (ix Index) SourceCollections(sid string) (result []string, err error)
- func (ix Index) SourceIdentifiers() (result []string, err error)
- type SelectResponse
Constants ¶
const DefaultFacetLimit = 100000
Variables ¶
This section is empty.
Functions ¶
func FindLiveSolrServer ¶ added in v0.1.248
FindLiveSolrServer returns the current live SOLR URL.
func FindNonliveSolrServer ¶ added in v0.1.248
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.
Types ¶
type FacetMap ¶
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 ¶
AllowedOnly returns an error if facets values contain non-zero values that are not explicitly allowed.
func (FacetMap) EqualSizeNonZero ¶
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 ¶
Index allows to send various queries to SOLR.
func (Index) AllowedKeys ¶
AllowedKeys checks for a query and facet field, whether the values contain only allowed values.
func (Index) EqualSizeNonZero ¶
EqualSizeNonZero checks, if given facet field values have the same size.
func (Index) EqualSizeTotal ¶
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) 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 (Index) Institutions ¶
Institutions returns a list of International Standard Identifier for Libraries and Related Organisations (ISIL), ISO 15511 identifiers.
func (Index) MinCount ¶
MinCount fails, if the number of records matching a value undercuts a given size.
func (Index) MinRatioPct ¶
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) Select ¶
func (ix Index) Select(query string) (r *SelectResponse, err error)
Select runs a select query.
func (Index) SelectLink ¶
SelectLink constructs a link to a JSON response.
func (Index) SourceCollections ¶
SourceCollections returns the collections for a given source identifier.
func (Index) SourceIdentifiers ¶
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.