Skip to content

tomesch/elasticsearch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#elasticsearch.R

#(This project is no longer maintained, if you would like to take over feel free to send me an email)

##Features (WIP) ###Document APIs

  • Index
  • Get
  • Delete
  • Update
  • Multi-get
  • Bulk

###Search APIs

  • Search

###Indices APIs

  • Create index
  • Delete index
  • Indices Exists
  • Open / Close Index API

##Installation You will need the devtools package in order to install this package

install.packages("devtools")
library(devtools)
install_github("tomesch/elasticsearch")
library(elasticsearch)

##Examples For the following series of examples we will be using a simplifed version of the Unicode Character Database. The data is formated so that it can be directly indexed in Elasticsearch via a bulk query. You can download the database here.

###Importing the data

# Read the database
requests = paste(readLines("/Users/tom/ucd.json"), collapse="\n")

# Create the client
es = ElasticsearchClient("http://localhost:9200")
# Index the data
bulk(es, requests)

###CRUD operations

# Index a new document
index(es, "ucd", "characters", 1, body='{"cp": "9999", "na": "My new character", "age": "23", "blk": "ASCII"}')
# Get it
get(es, "ucd", "characters", 1)
# Update it
update(es, "ucd", "characters", 1, '{"doc" : { "age" : 24}}')
# Delete it
delete(es, "ucd", "characters", 1)

###Search

# Search a character
search(es, body='{"query": {"match": {"na": "pile of poo"}}}')
# Run an aggregation
res = search(es, body='{"aggs" : {"blocks" : {"terms" : { "field" : "blk", "size": 0}}}}')
# And plot it
barplot(res$aggregations$blocks$buckets$doc_count)

About

Simple Elasticsearch client for R

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages