Skip to content

Instantly share code, notes, and snippets.

View kosho's full-sized avatar

Kosho Owa kosho

View GitHub Profile
@kosho
kosho / server.js
Created April 17, 2019 04:19
Elastic's APM enabled web service sample code
// Elastic's APM enabled web service sample code
var apm = require('elastic-apm-node').start({
serviceName: 'Sample web service',
secretToken: '',
serverUrl: ''
})
var http = require('http');
var server = http.createServer();
##################################################
# Kuromoji/ICU Tokenizer comparison Test
##################################################
# config/userdict_ja.txt
# ルークスカイウォーカー,ルーク スカイウォーカー,ルーク スカイウォーカー,カスタム名詞
DELETE app-search-test
PUT app-search-test
##################################################
# Cross Cluster Replication Example
##################################################
# On follower (remote), register "leader" (origin) cluster
PUT /_cluster/settings
{
"persistent" : {
"cluster" : {
@kosho
kosho / function_score-query-example.js
Last active December 5, 2018 01:36
Usage example of Function Score Query to control search relevancy.
##################################################
# Function Score Query Example
##################################################
# Note: `now` should be replaced by `2018-12-06` for expected results
# Prepare for items index
DELETE items
PUT items
@kosho
kosho / elasticsearch-sql-examples.js
Last active August 20, 2018 08:48
Elasticsearch SQL Example with Apache Log for Webinar
##################################################
# Elasticsearch SQL Example with Apache Log
##################################################
#
# Operations
#
POST _xpack/sql
{
input {
elasticsearch {
hosts => ["localhost:9200"]
index => ""
# user => "elastic"
# password => "changeme"
query => '{"query": {"match_all": {}}}'
}
}
filter {}
# via http://apple.stackexchange.com/questions/39430/automatically-scan-cycle-through-safari-tabs
tell application "Safari"
repeat
repeat with i from (count of tabs of window 1) to 1 by -1
set current tab of window 1 to tab i of window 1
delay 10
end repeat
end repeat
end tell
# Japan Population 2017
DELETE japan-population-2017
PUT japan-population-2017
{
"settings": {
"number_of_replicas": 0
, "number_of_shards": 1
},
<!DOCTYPE html>
<html>
<style>
span.st-snippet em {
font-style: normal;
font-weight: bold;
background: yellow;
}
</style>
<head>
@kosho
kosho / site-search.html
Last active July 10, 2018 07:51
Elastic Site Serach Example
<!DOCTYPE html>
<html>
<head></head>
<body>
<form>
<input type="text" class="st-default-search-input" />
</form>
<script type="text/javascript">
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);