Learn R Programming

solr (version 0.1.6)

solr_stats: Get Solr stats.

Description

Get Solr stats.

Usage

solr_stats(q = "*:*", stats.field = NULL, stats.facet = NULL, wt = "json", start = 0, rows = 0, key = NULL, base = NULL, callopts = list(), raw = FALSE, parsetype = "df", verbose = TRUE)

Arguments

q
Query terms, defaults to '*:*', or everything.
stats.field
The number of similar documents to return for each result.
stats.facet
You can not facet on multi-valued fields.
wt
Data type returned, defaults to 'json'
start
Record to start at, default to beginning.
rows
Number of records to return. Defaults to 10.
key
API key, if needed.
base
URL endpoint.
callopts
Call options passed on to httr::GET
raw
(logical) If TRUE, returns raw data in format specified by wt param
parsetype
(character) One of 'list' or 'df'
verbose
If TRUE (default) the url call used printed to console.

Value

XML, JSON, a list, or data.frame

References

See http://wiki.apache.org/solr/StatsComponent for more information on Solr stats.

See Also

solr_highlight, solr_facet, solr_search, solr_mlt

Examples

Run this code
## Not run: 
# url <- 'http://api.plos.org/search'
# solr_stats(q='science', stats.field='counter_total_all', base=url, raw=TRUE)
# solr_stats(q='title:"ecology" AND body:"cell"',
#    stats.field=c('counter_total_all','alm_twitterCount'), base=url)
# solr_stats(q='ecology', stats.field=c('counter_total_all','alm_twitterCount'),
#    stats.facet='journal', base=url)
# solr_stats(q='ecology', stats.field=c('counter_total_all','alm_twitterCount'),
#    stats.facet=c('journal','volume'), base=url)
# 
# # Get raw data, then parse later if you feel like it
# ## json
# out <- solr_stats(q='ecology', stats.field=c('counter_total_all','alm_twitterCount'),
#    stats.facet=c('journal','volume'), base=url, raw=TRUE)
# library(rjson)
# fromJSON(out)
# solr_parse(out) # list
# solr_parse(out, 'df') # data.frame
# 
# ## xml
# out <- solr_stats(q='ecology', stats.field=c('counter_total_all','alm_twitterCount'),
#    stats.facet=c('journal','volume'), base=url, raw=TRUE, wt="xml")
# library(XML)
# xmlParse(out)
# solr_parse(out) # list
# solr_parse(out, 'df') # data.frame
# 
# # Get verbose http call information
# library(httr)
# solr_stats(q='ecology', stats.field='alm_twitterCount', base=url,
#    callopts=verbose())
# ## End(Not run)

Run the code above in your browser using DataLab