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)
- func PrependHTTP(s string) string
- type FacetMap
- 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) 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) FacetQuery(query, facetField string) (r *SelectResponse, err error)
- 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) RandomCollection(sid string) (string, error)
- func (ix Index) RandomSource() (string, error)
- func (ix Index) Select(vs url.Values) (*SelectResponse, error)
- func (ix Index) SelectQuery(query string) (r *SelectResponse, err error)
- func (ix Index) SourceCollections(sid string) (result []string, err error)
- func (ix Index) SourceIdentifiers() (result []string, err error)
- type SelectResponse
Constants ¶
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
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.
func PrependHTTP ¶ added in v0.1.252
PrependHTTP prepends http, if necessary.
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. Used for reviews.
func (FacetMap) EqualSizeNonZero ¶
EqualSizeNonZero checks if frequencies of the given keys are the same and non-zero. Used for reviews.
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. Used for reviews.
func (Index) EqualSizeNonZero ¶
EqualSizeNonZero checks, if given facet field values have the same size. Used for reviews.
func (Index) EqualSizeTotal ¶
EqualSizeTotal checks, if given facet field values have the same size as the total number of records. Used for reviews.
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) FacetQuery ¶ added in v0.1.252
func (ix Index) FacetQuery(query, facetField string) (r *SelectResponse, err error)
FacetQuery runs a facet query.
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. Used for reviews.
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. Used for reviews.
func (Index) RandomCollection ¶ added in v0.1.252
RandomCollection returns a random collection for a source identifier.
func (Index) RandomSource ¶ added in v0.1.252
RandomSource returns a random source identifier.
func (Index) Select ¶
func (ix Index) Select(vs url.Values) (*SelectResponse, error)
Select allows to pass any parameter to select.
func (Index) SelectQuery ¶ added in v0.1.252
func (ix Index) SelectQuery(query string) (r *SelectResponse, err error)
SelectQuery runs a select query.
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 {
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.