knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Algolia Configuration

Interactive Use

config <- algoliar::create_config(path_index_json = "path_to_your_index.json", 
                                  app_id = "your_algolia_application_id",
                                  api_key = "your_algolia_api_key",
                                  index_name = "your_algolia_index_name")

Continious Integration

Using environment variables is necessary if continious integration services (e.g. Travis, Appveyor or GitLab CI). In this case you need to specify: - algolia_app_id: application id - algolia_api_key: api key with sufficient rights (created in Algolia dashboard) - algolia_index_name: index name (created in Algolia dashboard)

All three are defined / created in the Algolia dashboard.

Sys.setenv(algolia_app_id = "your_algolia_application_id",
           algolia_api_key = "your_algolia_api_key",
           algolia_index_name = "your_algolia_index_name")

Finally only one parameter is not not explicitly defined yet. It is the path to to index.json that should be uploaded to Algolia. We use the Algolia search in tandem with the Hugo theme Academic. Thus the default value is public/index.json, which usually is the standard deploy location after generating
the website with blogdown::build_site().

In this case there is no need to call the algolia::create_config() function explicitly to upload the index.json to Algolia using the function algoliar::algolia_post_batch().

## Upload new index.json to algolia, no need to call algoliar::create_config() 
algoliar::algolia_post_batch()

In cases where this default is not correct only the path_index_json needs to be set to the correct path/url as shown below:

## Upload new index.json to algolia, calling algoliar::create_config() required!
algoliar::algolia_post_batch(algoliar::create_config("mypath/index.json"))

Using the R package algoliar now automates the formerly manual workflow, which is described in detail in the documentation of the Hugo theme Academic.

Other API calls

Get

algoliar::algolia_get(config)

Content

Content of "index.json" at Algolia as data.frame.

algoliar::algolia_content(config)

Delete Index

For completly deleting an Algolia "index_name" run:

algoliar::algolia_delete_index(config)

This means that it needs to be created manually again from the Algolia dashboard, since a creation method is not implemented in the R Package



KWB-R/algoliar documentation built on Sept. 9, 2019, 3:16 p.m.