## Not run:
# url <- 'http://api.plos.org/search'
#
# # Facet on a single field
# solr_facet(q='*:*', facet.field='journal', base=url)
#
# # Facet on multiple fields
# solr_facet(q='alcohol', facet.field=c('journal','subject'), base=url)
#
# # Using mincount
# solr_facet(q='alcohol', facet.field='journal', facet.mincount='500', base=url)
#
# # Using facet.query to get counts
# solr_facet(q='*:*', facet.field='journal', facet.query=c('cell','bird'), base=url)
#
# # Date faceting
# solr_facet(q='*:*', base=url, facet.date='publication_date',
# facet.date.start='NOW/DAY-5DAYS', facet.date.end='NOW', facet.date.gap='+1DAY')
#
# # Range faceting
# solr_facet(q='*:*', base=url, facet.range='counter_total_all',
# facet.range.start=5, facet.range.end=1000, facet.range.gap=10)
#
# # Range faceting with > 1 field, same settings
# solr_facet(q='*:*', base=url, facet.range=c('counter_total_all','alm_twitterCount'),
# facet.range.start=5, facet.range.end=1000, facet.range.gap=10)
#
# # Range faceting with > 1 field, different settings
# solr_facet(q='*:*', base=url, facet.range=c('counter_total_all','alm_twitterCount'),
# f.counter_total_all.facet.range.start=5, f.counter_total_all.facet.range.end=1000,
# f.counter_total_all.facet.range.gap=10, f.alm_twitterCount.facet.range.start=5,
# f.alm_twitterCount.facet.range.end=1000, f.alm_twitterCount.facet.range.gap=10)
#
# # Get raw json or xml
# ## json
# solr_facet(q='*:*', facet.field='journal', base=url, raw=TRUE)
# ## xml
# solr_facet(q='*:*', facet.field='journal', base=url, raw=TRUE, wt='xml')
#
# # Get raw data back, and parse later, same as what goes on internally if
# # raw=FALSE (Default)
# out <- solr_facet(q='*:*', facet.field='journal', base=url, raw=TRUE)
# solr_parse(out)
# out <- solr_facet(q='*:*', facet.field='journal', base=url, raw=TRUE,
# wt='xml')
# solr_parse(out)
#
# # Using the USGS BISON API (http://bison.usgs.ornl.gov/services.html#solr)
# ## The occurrence endpoint
# base="http://bisonapi.usgs.ornl.gov/solr/occurrences/select"
# solr_facet(q='*:*', facet.field='year', base=url)
# solr_facet(q='*:*', facet.field='state_code', base=url)
# solr_facet(q='*:*', facet.field='basis_of_record', base=url)
# ## End(Not run)
Run the code above in your browser using DataLab