as_search: Article search

Description Usage Arguments Details References Examples

Description

Article search

Usage

1
2
3
4
as_search(q, fq = NULL, sort = NULL, begin_date = NULL, end_date = NULL,
  key = NULL, fl = NULL, hl = FALSE, page = 0, all_results = FALSE,
  try_flatten = FALSE, facet_field = NULL, facet_filter = NULL,
  sleep = 2, ..., callopts = list())

Arguments

q

Search query term. Search is performed on the article body, headline and byline.

fq

Filtered search query using standard Lucene syntax. The filter query can be specified with or without a limiting field: label. See fq_fields for the filter query fields.

sort

(character) Default NULL. One of newest or oldest . By default, search results are sorted by their relevance to the query term (q). Use the sort parameter to sort by pub_date.

begin_date

Begin date - Restricts responses to results with publication dates of the date specified or later. In the form YYYYMMDD

end_date

End date - Restricts responses to results with publication dates of the date specified or earlier. In the form YYYYMMDD

key

your New York Times API key; pass in, or loads from .Renviron as NYTIMES_AS_KEY. See rtimes-package for info on rate limits.

fl

(character) Vector of fields to return. default: all fields

hl

(logical) Highlight or not, default: FALSE

page

Page number. The value of page corresponds to a set of 10 results (it does not indicate the starting number of the result set). For example, page=0 corresponds to records 0-9. To return records 10-19, set page to 1, not 10.

all_results

(logical) return all results. Default: FALSE

try_flatten

(logical) attempt to completely flatten data.frame, which may fail in some cases as its hard to account for all edge cases. Default: FALSE

facet_field

(character) Specifies the sets of facet values to include in the facets array at the end of response, which collects the facet values from all the search results. By default no facet fields will be returned. See Details for options.

facet_filter

(logical) Fields to facet on, as vector. When set to TRUE, facet counts will respect any applied filters (fq, date range, etc.) in addition to the main query term. To filter facet counts, specifying at least one facet_field is required.

sleep

(integer) seconds to sleep between successive requests, only used when all_results=TRUE

...

Futher args pass into query

callopts

Curl options (debugging tools mostly) passed to HttpClient

Details

fl parameter options are:

facet_field param options are:

References

http://developer.nytimes.com/docs/read/article_search_api_v2 http://developer.nytimes.com/article_search_v2.json#/README

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
# basic search - copyright, metadata, data, and facet slots
(x <- as_search(q="bailout", begin_date = "20081001", 
  end_date = '20081005'))
x$copyright
x$meta
x$data
x$facet
Sys.sleep(1)

as_search(q="money", fq = 'The New York Times', fl = c('word_count', 
  'snippet', 'headline'))
Sys.sleep(1)
x <- as_search(q="bailout", hl = TRUE)
x$data$snippet
Sys.sleep(1)

# all results
(x <- as_search(q="bailout", begin_date = "20081001", 
  end_date = '20081003', all_results = TRUE))
x$meta
x$data
Sys.sleep(1)

# facetting
as_search(q="bailout", facet_field = 'section_name', begin_date = "20081001",
   end_date = '20081201')
Sys.sleep(1)
## with facet filtering
as_search(q="bailout", facet_field = 'section_name', begin_date = "20081001",
   end_date = '20081201', facet_filter = TRUE)
   
# curl options
x <- as_search(q="bailout", begin_date = "20081001", 
  end_date = '20081005', callopts = list(verbose = TRUE))

## End(Not run)

rtimes documentation built on May 2, 2019, 2:06 p.m.