Skip to content

Elasticsearch

illyfrancis edited this page Sep 22, 2015 · 4 revisions

Notes

http://techbus.safaribooksonline.com/video/programming/9781491910795/-databases-and-datastores/141-2014-10-23?query=((elasticsearch))#snippet

use cases

  • searching pieces of pure text
  • searching text + structured data (products, user profiles, application logs)
  • pure aggregated data (stats, metrics, etc)
  • geo search
  • distributed JSON document DB (anything) - not really a use case

at high level

  • is a database, like other
  • document oriented
  • clusters
  • built on Lucene
  • build on an IR foundation (information retrieval)
  • can perform fancy tricks with inverted indexes and automata (???)

basics of ES api

getting data in

storing a document

verb: PUT
index: literature
type: quote
docId: one
document: {json}

curl -XPUT http://localhost:9200/literature/quote/one -d'
{
  "person": "Jack Handy",
  "said": "The face of a child can say it all, especially the mouth part of the face"
}'

where does the document go

indexes live in the cluster, documents live in indexes

Key points

Documents

  • a single arbitrary JSON object
  • stored as a text blob + indexes on fields
  • all fields get an inverted index(es)

Types

  • defines the schema for documents
  • defines indexing rules as well
{
  "human" : {
    "properties" : {
      "person" : { "type": "string" },
      "age" : { "type" : "integer" } }}}

Indexes

  • largest building block in ES
  • container for documents / types
  • composable

Document storage

11:36

Document, routing, Shards

Querying

A simple query

verb: POST
index: literature
type: quote
action: _search
search body: {json}

curl -XPOST http://localhost:9200/literature/quote/_search -d'
{ 
  "query": {
    "match": {
      "person": "jack" }}}'

Natural language search

Clone this wiki locally