Skip to content

Instantly share code, notes, and snippets.

View deerawan's full-sized avatar

Budi Irawan deerawan

View GitHub Profile
@deerawan
deerawan / es-delete-document.js
Last active April 28, 2018 12:09
Elasticsearch delete document
client.delete({
index: 'student',
type: '_doc',
id: '1'
})
.then(res => console.log(JSON.stringify(res)))
.catch(err => console.error(err));
@deerawan
deerawan / es-search-document.js
Last active April 28, 2018 12:20
Elasticsearch Search document
client.search({
index: 'student',
type: '_doc',
body: {
query: {
match: { name: 'John' }
}
}
})
.then(res => console.log(JSON.stringify(res)))
@deerawan
deerawan / es-update-document.js
Last active April 28, 2018 12:19
Elasticsearch update document
client.update({
index: 'student',
type: '_doc',
id: '1',
body: {
doc: {
hobby: 'swimming'
}
}
})
@deerawan
deerawan / es-create-document-id.js
Last active April 28, 2018 12:21
Elasticsearch create document with ID specified
client.index({
index: 'student',
type: '_doc',
id: 1,
body: {
name: 'C. Ronaldo',
age: 33,
hobby: 'football'
}
})
@deerawan
deerawan / es-get-document.js
Last active April 28, 2018 12:22
Elasticsearch Get Documents
client.search({
index: 'student',
type: '_doc',
})
.then(res => console.log(JSON.stringify(res)))
.catch(err => console.error(err));
@deerawan
deerawan / es-create-document.js
Last active April 28, 2018 12:22
Elasticsearch create document
client.index({
index: 'student',
type: '_doc',
body: {
name: 'John Doe',
age: 17,
hobby: 'basketball'
}
})
.catch(err => console.error(err));
@deerawan
deerawan / es-connect.js
Last active April 28, 2018 12:23
Node Elasticsearch Client
const es = require('elasticsearch');
const client = es.Client({ host: 'http://localhost:9200' });
client.ping()
.then(res => console.log('connection success', res))
.catch(err => console.error('wrong connection', err));
@deerawan
deerawan / docker-compose-elasticsearch.yml
Last active September 5, 2018 09:39
Docker compose Elasticsearch 6.2.4 + Kibana 6.2.4
---
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
@deerawan
deerawan / dockerfile.yml
Created April 12, 2018 08:55
base node dockerfile
FROM node:6.11.1
# Copy package.json and package-lock.json
COPY package.json .
COPY package-lock.json .
RUN npm install --quiet
COPY . .
var scores = [1, 2, 3, 4];
function multiplyTwo(score) {
return score * 2;
}
var result = scores.map(multiplyTwo);