This project uses Docker and Docker Compose to launch you into an environment with spark locally installed and some data prepopulated.
- install Docker (http://docs.docker.com/mac/started/)
- brew install docker-machine
- brew install docker
- brew install docker-compose
- docker-machine create --driver virtualbox learn-elasticsearch
- docker-machine env learn-elasticsearch
- eval "$(docker-machine env learn-elasticsearch)"
- export DOCKER_CERT_PATH=$HOME/.docker/machine/machines/learn-elasticsearch
- export DOCKER_MACHINE_NAME=learn-elasticsearch
from the project directory. The build will take a long time...
- docker-compose up
PUT http://address:9200/megacorp/employee/1
{ "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests": [ "sports", "music" ] }
- megacorp is index name
- employee is type name
- 1 is the document id
PUT http://address:9200/megacorp/employee/2 { "first_name" : "Jane", "last_name": "Smith", "age" : 32, "about" : "I like to collect rock albums", "interests": [ "music" ] }
PUT http://address:9200/megacorp/employee/3 { "first_name" : "Douglas", "last_name": "Fir", "age" : 35, "about": "I like to build cabinets", "interests": [ "forestry" ] }
http://address:5601
- set the index that you want to view to megacorp
- view the data under the discover tab
GET http://address:9200/megacorp/employee/1
{ "_index": "megacorp", "_type": "employee", "_id": "1", "_version": 5, "found": true, "_source": { "first_name": "John", "last_name": "Smith", "age": 25, "about": "I love to go rock climbing", "interests": [ "sports", "music" ], } }
GET http://address:9200/megacorp/employee/_search?q=last_name:Smith
{ "took": 6, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 2, "max_score": 0.2876821, "hits": [ { "_index": "megacorp", "_type": "employee", "_id": "2", "_score": 0.2876821, "_source": { "first_name": "Jane", "last_name": "Smith", "age": 32, "about": "I like to collect rock albums", "interests": [ "music" ], } }, { "_index": "megacorp", "_type": "employee", "_id": "1", "_score": 0.2876821, "_source": { "first_name": "John", "last_name": "Smith", "age": 25, "about": "I love to go rock climbing", "interests": [ "sports", "music" ], } } ], } }
POST http://address:9200/megacorp/employee/_search
{ "query" : { "match" : { "last_name" : "Smith" } } }
{ "took": 6, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 2, "max_score": 0.2876821, "hits": [ { "_index": "megacorp", "_type": "employee", "_id": "2", "_score": 0.2876821, "_source": { "first_name": "Jane", "last_name": "Smith", "age": 32, "about": "I like to collect rock albums", "interests": [ "music" ], } }, { "_index": "megacorp", "_type": "employee", "_id": "1", "_score": 0.2876821, "_source": { "first_name": "John", "last_name": "Smith", "age": 25, "about": "I love to go rock climbing", "interests": [ "sports", "music" ], } } ], } }
POST http://address:9200/megacorp/employee/_search
{ "query" : { "match" : { "about" : "rock climbing" } } }
{ "took": 4, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": 2, "max_score": 0.53484553, "hits": [ { "_index": "megacorp", "_type": "employee", "_id": "1", "_score": 0.53484553, "_source": { "first_name": "John", "last_name": "Smith", "age": 25, "about": "I love to go rock climbing", "interests": [ "sports", "music" ], } }, { "_index": "megacorp", "_type": "employee", "_id": "2", "_score": 0.26742277, "_source": { "first_name": "Jane", "last_name": "Smith", "age": 32, "about": "I like to collect rock albums", "interests": [ "music" ], } } ], } }