## Not run:
# url <- 'http://api.plos.org/search'
#
# # Basic group query
# solr_group(q='ecology', group.field='journal', group.limit=3, fl='id,score', base=url)
# solr_group(q='ecology', group.field='journal', group.limit=3, fl='article_type', base=url)
#
# # Different ways to sort (notice diff btw sort of group.sort)
# # note that you can only sort on a field if you return that field
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score'), base=url)
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score','alm_twitterCount'),
# group.sort='alm_twitterCount desc', base=url)
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score','alm_twitterCount'),
# sort='score asc', group.sort='alm_twitterCount desc', base=url)
#
# # Two group.field values
# out <- solr_group(q='ecology', group.field=c('journal','article_type'), group.limit=3, fl='id',
# base=url, raw=TRUE)
# solr_parse(out)
# solr_parse(out, 'df')
#
# # Get two groups, one with alm_twitterCount of 0-10, and another group with 10 to infinity
# solr_group(q='ecology', group.limit=3, fl=c('id','alm_twitterCount'),
# group.query=c('alm_twitterCount:[0 TO 10]','alm_twitterCount:[10 TO *]'),
# base=url)
#
# # Use of group.format and group.simple.
# ## The raw data structure of these two calls are slightly different, but
# ## the parsing inside the function outputs the same results. You can of course
# ## set raw=TRUE to get back what the data actually look like
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score'),
# group.format='simple', base=url)
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score'),
# group.format='grouped', base=url)
# solr_group(q='ecology', group.field='journal', group.limit=3, fl=c('id','score'),
# group.format='grouped', group.main='true', base=url)
# ## End(Not run)
Run the code above in your browser using DataLab