Learn R Programming

elastic (version 0.7.6)

mapping: Mapping management

Description

Mapping management

Usage

mapping_create(index, type, body, ...)
mapping_get(index = NULL, type = NULL, ...)
field_mapping_get(index = NULL, type = NULL, field, include_defaults = FALSE, ...)
type_exists(index, type, ...)

Arguments

index
(character) An index
type
(character) A document type
body
(list) Either a list or json, representing the query.
...
Curl options passed on to HEAD or other http verbs
field
(character) One or more field names
include_defaults
(logical) Whether to return default values

Details

Find documentation for each function at:

Examples

Run this code
## Not run: 
# # Used to check if a type/types exists in an index/indices
# type_exists(index = "plos", type = "article")
# type_exists(index = "plos", type = "articles")
# type_exists(index = "shakespeare", type = "line")
# 
# # The put mapping API allows to register specific mapping definition for a specific type.
# ## a good mapping body
# body <- list(citation = list(properties = list(
#  journal = list(type="string"),
#  year = list(type="long")
# )))
# if (!index_exists("plos")) index_create("plos")
# mapping_create(index = "plos", type = "citation", body=body)
# 
# ### or as json
# body <- '{
#   "citation": {
#     "properties": {
#       "journal": { "type": "string" },
#       "year": { "type": "long" }
# }}}'
# mapping_create(index = "plos", type = "citation", body=body)
# mapping_get("plos", "citation")
# 
# ## A bad mapping body
# body <- list(things = list(properties = list(
#   journal = list("string")
# )))
# # mapping_create(index = "plos", type = "things", body=body)
# 
# # Get mappings
# mapping_get('_all')
# mapping_get(index = "plos")
# mapping_get(index = c("shakespeare","plos"))
# mapping_get(index = "shakespeare", type = "act")
# mapping_get(index = "shakespeare", type = c("act","line"))
# 
# # Get field mappings
# plosdat <- system.file("examples", "plos_data.json", package = "elastic")
# docs_bulk(plosdat)
# field_mapping_get(index = "_all", type=c('article', 'line'), field = "text")
# field_mapping_get(index = "plos", type = "article", field = "title")
# field_mapping_get(index = "plos", type = "article", field = "*")
# field_mapping_get(index = "plos", type = "article", field = "title", include_defaults = TRUE)
# field_mapping_get(type = c("article","record"), field = c("title","class"))
# field_mapping_get(type = "a*", field = "t*")
# 
# # Create geospatial mapping
# file <- system.file("examples", "gbif_geopoint.json", package = "elastic")
# docs_bulk(file)
# body <- '{
#  "properties" : {
#    "location" : { "type" : "geo_point" }
#  }
# }'
# mapping_create("gbifgeopoint", "record", body = body)
# ## End(Not run)

Run the code above in your browser using DataLab