Skip to content

Instantly share code, notes, and snippets.

View alexbrasetvik's full-sized avatar

Alex Brasetvik alexbrasetvik

View GitHub Profile
@alexbrasetvik
alexbrasetvik / ssl-acl.yaml
Created January 28, 2013 10:17
SSL-only-ACL
rules:
- paths: ['.*']
conditions:
- ssl: # Note: nested under "conditions", which is in the same object as "paths" and "action".
require: true
action: allow
@alexbrasetvik
alexbrasetvik / reindex.py
Last active December 12, 2015 04:28
Elasticsearch reindexing/migrating
import json, requests
source_cluster = 'https://abc1234-us-east-1.foundcluster.com:9243'
destination_cluster = 'http://c0ffee-us-east-1.foundcluster.com:9200'
source_session = requests.session()
source_session.auth = ('user', 'pass')
destination_session = requests.session()
destination_session.auth = ('user', 'pass')
@alexbrasetvik
alexbrasetvik / analysis.yaml
Created October 8, 2013 22:08
Using an edgeNGram index analyzer and a simpler search analyzer for partial filename purposes.
# Switch to the Analysis-tab to see how these samples get analyzed.
text:
- My_second_file_created_at_2012.01.13.pdf
- Another file.txt
analyzer:
filename_index:
type: custom
tokenizer: filename
@alexbrasetvik
alexbrasetvik / analysis.yaml
Created November 13, 2013 12:20
Using an edgeNGram index analyzer and a simpler search analyzer for partial filename purposes.
# Switch to the Analysis-tab to see how these samples get analyzed.
text:
- My_second_file_created_at_2012.01.13.pdf
- Another file.txt
analyzer:
filename_index:
type: custom
tokenizer: filename
@alexbrasetvik
alexbrasetvik / analysis.yaml
Created November 14, 2013 10:29
Standard tokenization, but without the lowercasing and stopword removal.
text: This text will be used if nothing else is specified.
analyzer:
standard_tokenize_only:
type: custom
tokenizer: standard
# Switch to the "Analysis"-tab to see how the text gets tokenized by default.
standard:
type: standard
@alexbrasetvik
alexbrasetvik / analysis.yaml
Created November 22, 2013 08:24
Simple example of nested mappings, with queries that require a key to match as well.
# Here you could have various analyzers for different string-types.
# "text_value" and "name_value" should probably have different ones.
@alexbrasetvik
alexbrasetvik / analysis.yaml
Created November 24, 2013 17:00
Demo that "prefix"-query does not analyze the query text.
analyzer:
sample:
text:
- Jon Snow
- Big Ben
tokenizer: standard
type: custom
filter:
- lowercase
_id: 1
foo: null
bar: null
---
_id: 2
foo: ''
bar: ''
---
_id: 3
foo: bar
text:
- Michael
- Heaney
- Heavey
analyzer:
metaphone:
type: custom
tokenizer: standard
@alexbrasetvik
alexbrasetvik / documents.yaml
Created December 20, 2013 11:30
Simple examples of aggregations on CPU metrics.
# Sample data points.
# These could e.g. be metrics reported by collectd to logstash.
host: app1
cpu: 87.0
---
host: app1
cpu: 1.23
---
host: app2