Title: | Simple Access to Algolia Search REST API |
---|---|
Description: | Simple Access to Algolia REST API (https://www.algolia.com/doc/rest-api/search/). |
Authors: | Michael Rustler [aut, cre] , Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
Maintainer: | Michael Rustler <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-11 03:13:42 UTC |
Source: | https://github.com/KWB-R/algoliar |
Get Algolia "content"
algolia_content(config = create_config())
algolia_content(config = create_config())
config |
config as retrieved by create_config() (default: create_config()) |
data.frame with content of Algolia index
## Not run: algolia_content() ## End(Not run)
## Not run: algolia_content() ## End(Not run)
Delete Algolia Index
algolia_delete_index(config = create_config())
algolia_delete_index(config = create_config())
config |
config as retrieved by create_config() (default: create_config()) |
deletes "index_name" (config$index_name) at Algolia URL (config$api_url) in case that provided API Key has sufficient rights!
<https://www.algolia.com/doc/api-client/methods/api-keys/>
## Not run: algolia_content() ## End(Not run)
## Not run: algolia_content() ## End(Not run)
Algolia "GET"
algolia_get(config = create_config())
algolia_get(config = create_config())
config |
config as retrieved by create_config() (default: create_config()) |
## Not run: algolia_get() ## End(Not run)
## Not run: algolia_get() ## End(Not run)
Performs Algolia Post Batch
algolia_post_batch(config = create_config(), threshold_kb = 10)
algolia_post_batch(config = create_config(), threshold_kb = 10)
config |
config as retrieved by create_config() (default: create_config()) |
threshold_kb |
(default: 10), 10 KB is threshold for free Algolia usage, 20 KB for paid for details: https://www.algolia.com/doc/faq/basics/is-there-a-size-limit-for-my-index-records/ |
performs batch operation at provided Algolia url (config$api_url) in case of sufficient rights of the provided API key (see: <https://www.algolia.com/doc/api-client/methods/api-keys/>)
<https://www.algolia.com/doc/rest-api/search/#batch-write-operations>
## Not run: algolia_post_batch() ## End(Not run)
## Not run: algolia_post_batch() ## End(Not run)
Check Algolia Threshold KB
check_threshold_kb(index_list, threshold_kb = 10)
check_threshold_kb(index_list, threshold_kb = 10)
index_list |
as retrieved by algoliar::read_index_list() |
threshold_kb |
(default: 10), 10 KB is threshold for free Algolia usage, 20 KB for paid for details: https://www.algolia.com/doc/faq/basics/is-there-a-size-limit-for-my-index-records/ |
index_list respecting Algolia threshold KB, by reducing the "content" length accordingly
Create Algolia Configuration
create_config(path_index_json = "public/index.json", app_id = Sys.getenv("algolia_app_id"), api_key = Sys.getenv("algolia_api_key"), index_name = Sys.getenv("algolia_index_name"))
create_config(path_index_json = "public/index.json", app_id = Sys.getenv("algolia_app_id"), api_key = Sys.getenv("algolia_api_key"), index_name = Sys.getenv("algolia_index_name"))
path_index_json |
path to index.json (default: "public/index.json") |
app_id |
app_id Application ID. This is your unique application identifier. It's used to identify you when using Algolia's API. (see: create a API key with valid scope in the Algolia Dashboard), (default: Sys.getenv("algolia_app_id")) |
api_key |
api_key (default: Sys.getenv("algolia_api_key"), <https://www.algolia.com/doc/api-client/methods/api-keys/> |
index_name |
name of Algolia index name (default: Sys.getenv("algolia_index_name")) |
list with algolia config
<https://www.algolia.com/doc/guides/getting-started/quick-start/tutorials/getting-started-with-the-dashboard/>
## Not run: ######################################################################## ### Option A) Interactive R Session ######################################################################## config <- 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") ######################################################################## ### Option B) Environment variable ######################################################################## Sys.setenv(algolia_app_id = "your_algolia_application_id", algolia_api_key = "your_algolia_api_key", algolia_index_name = "your_algolia_index_name") ### With default path to index.json ("public/index.json") ### (i.e standard output path after running blogdown::build_site() for ### theme hugo-academic (https://github.com/gcushen/hugo-academic/) config <- create_config() ### With user defined path or url to index.json "public/index.json" config <- create_config(path_index_json = "https://mhugoacademicsite.de/index.json") ## End(Not run)
## Not run: ######################################################################## ### Option A) Interactive R Session ######################################################################## config <- 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") ######################################################################## ### Option B) Environment variable ######################################################################## Sys.setenv(algolia_app_id = "your_algolia_application_id", algolia_api_key = "your_algolia_api_key", algolia_index_name = "your_algolia_index_name") ### With default path to index.json ("public/index.json") ### (i.e standard output path after running blogdown::build_site() for ### theme hugo-academic (https://github.com/gcushen/hugo-academic/) config <- create_config() ### With user defined path or url to index.json "public/index.json" config <- create_config(path_index_json = "https://mhugoacademicsite.de/index.json") ## End(Not run)
Pepare Batch Json
prepare_batch_json(config = create_config(), threshold_kb = 10, encoding = "UTF-8", ...)
prepare_batch_json(config = create_config(), threshold_kb = 10, encoding = "UTF-8", ...)
config |
config as retrieved by create_config() (default: create_config()) |
threshold_kb |
(default: 10), 10 KB is threshold for free Algolia usage, 20 KB for paid for details: https://www.algolia.com/doc/faq/basics/is-there-a-size-limit-for-my-index-records/ |
encoding |
encoding (default: "UTF-8") |
... |
additional arguments passed to jsonlite::read_json() |
## Not run: batch_json <- prepare_batch_json() ## End(Not run)
## Not run: batch_json <- prepare_batch_json() ## End(Not run)
Read Index.Json
read_index_json(path = "public/index.json")
read_index_json(path = "public/index.json")
path |
path or url to index.json (default: "public/index.json") |
imported index.json
## Not run: index_json <- read_index_json(path = "public/index.json") ## End(Not run)
## Not run: index_json <- read_index_json(path = "public/index.json") ## End(Not run)
Read Index.Json As List
read_index_list(path = "public/index.json", encoding = "UTF-8", ...)
read_index_list(path = "public/index.json", encoding = "UTF-8", ...)
path |
path or url to index.json (default: "public/index.json") |
encoding |
encoding (default: "UTF-8") |
... |
additional arguments passed to jsonlite::read_json() |
imported index.json as list
## Not run: index_list <- read_index_list(path = "public/index.json") ## End(Not run)
## Not run: index_list <- read_index_list(path = "public/index.json") ## End(Not run)