elastic
ne pas essayer de capturer des types de données à partir de votre entrée data.frame ou liste à docs_bulk()
- Nous pourrions penser à essayer de faire cela, mais j'imagine que les types de données R ne correspondraient pas exactement aux types Elasticsearch - pourraient jouer avec essayer de cartographier les types de données. Voici comment je le ferais:
library('elastic')
connect()
factice data.frame
df <- data.frame(
date = as.POSIXct(seq(from = as.Date("2016-10-01"),
to = as.Date("2016-10-31"), by = 'day')),
num = 1:31
)
Créer une correspondance, soit sous forme d'une liste ou une chaîne JSON
mapping <- list(
world = list(properties = list(
date = list(
type = "date",
format = "yyyy-mm-dd HH:mm:ss"
),
num = list(type = "long")
)))
Faire l'index
index_create(index = "hello")
Créer le mappage dans l'index
mapping_create(index = "hello", type = "world", body = mapping)
Obtenez le mappage
mapping_get("hello")
#> $hello
#> $hello$mappings
#> $hello$mappings$world
#> $hello$mappings$world$properties
#> $hello$mappings$world$properties$date
#> $hello$mappings$world$properties$date$type
#> [1] "date"
#>
#> $hello$mappings$world$properties$date$format
#> [1] "yyyy-mm-dd HH:mm:ss"
#>
#>
#> $hello$mappings$world$properties$num
#> $hello$mappings$world$properties$num$type
#> [1] "long"
charge en vrac data.frame
docs_bulk(df, index = "hello", type = "world")
Recherche sur l'indice
Search("hello")
Merci, ça m'a aidé. Dans le format, le mois doit être MM – Sonny