Package 'algoliar'

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

Help Index


Get Algolia "content"

Description

Get Algolia "content"

Usage

algolia_content(config = create_config())

Arguments

config

config as retrieved by create_config() (default: create_config())

Value

data.frame with content of Algolia index

Examples

## Not run: 
algolia_content()

## End(Not run)

Delete Algolia Index

Description

Delete Algolia Index

Usage

algolia_delete_index(config = create_config())

Arguments

config

config as retrieved by create_config() (default: create_config())

Value

deletes "index_name" (config$index_name) at Algolia URL (config$api_url) in case that provided API Key has sufficient rights!

See Also

<https://www.algolia.com/doc/api-client/methods/api-keys/>

Examples

## Not run: 
algolia_content()

## End(Not run)

Algolia "GET"

Description

Algolia "GET"

Usage

algolia_get(config = create_config())

Arguments

config

config as retrieved by create_config() (default: create_config())

Examples

## Not run: 
algolia_get()

## End(Not run)

Performs Algolia Post Batch

Description

Performs Algolia Post Batch

Usage

algolia_post_batch(config = create_config(), threshold_kb = 10)

Arguments

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/

Value

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/>)

See Also

<https://www.algolia.com/doc/rest-api/search/#batch-write-operations>

Examples

## Not run: 
algolia_post_batch()

## End(Not run)

Check Algolia Threshold KB

Description

Check Algolia Threshold KB

Usage

check_threshold_kb(index_list, threshold_kb = 10)

Arguments

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/

Value

index_list respecting Algolia threshold KB, by reducing the "content" length accordingly


Create Algolia Configuration

Description

Create Algolia Configuration

Usage

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"))

Arguments

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"))

Value

list with algolia config

See Also

<https://www.algolia.com/doc/guides/getting-started/quick-start/tutorials/getting-started-with-the-dashboard/>

Examples

## 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

Description

Pepare Batch Json

Usage

prepare_batch_json(config = create_config(), threshold_kb = 10,
  encoding = "UTF-8", ...)

Arguments

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()

Examples

## Not run: 
batch_json <- prepare_batch_json()

## End(Not run)

Read Index.Json

Description

Read Index.Json

Usage

read_index_json(path = "public/index.json")

Arguments

path

path or url to index.json (default: "public/index.json")

Value

imported index.json

Examples

## Not run: 
index_json <- read_index_json(path = "public/index.json")

## End(Not run)

Read Index.Json As List

Description

Read Index.Json As List

Usage

read_index_list(path = "public/index.json", encoding = "UTF-8", ...)

Arguments

path

path or url to index.json (default: "public/index.json")

encoding

encoding (default: "UTF-8")

...

additional arguments passed to jsonlite::read_json()

Value

imported index.json as list

Examples

## Not run: 
index_list <- read_index_list(path = "public/index.json")

## End(Not run)