Skip to content

Instantly share code, notes, and snippets.

View ianAndrewClark's full-sized avatar

Ian Clark ianAndrewClark

View GitHub Profile
@drlongnecker
drlongnecker / FindTODO.ps1
Created December 27, 2011 16:52
Finding TODOs and Reporting in PowerShell
#full details now available: http://tiredblogger.wordpress.com/2011/12/28/finding-todos-and-reporting-in-powershell/
param(
#this is appalling; there has to be a better way to get the raw name of "this" directory.
[string]$DirectoryMask = (get-location),
[array]$Include =
@("*.spark","*.cs","*.js","*.coffee","*.rb"),
[array]$Exclude =
@("fubu-content","packages","build","release"),
[switch]$Html,
@robcowie
robcowie / memoise.py
Created November 11, 2011 11:30
Python memoisation decorator
from functools import wraps
def memoise(wrapped):
cache = {}
@wraps(wrapped)
def wrapper(*args, **kwargs):
key = (args, tuple(sorted(kwargs.items())))
if key not in cache:
@ppearcy
ppearcy / gist:1279879
Created October 12, 2011 00:26
ES synonym failure on 0.17.8
# Here are the contents of the synonym file that is located here: analysis/synonym_test.txt
test1, a+b
test2, b+c
test3, d/c
work, business
# Create the index
curl -XPOST localhost:9200/es-syntest -d '{
"settings" : {
"number_of_shards" : 1,
@vshkurin
vshkurin / gist:1109136
Created July 27, 2011 10:50
ElasticSearch Test Queries
# Index
---------------------------------------------------------------------
curl -XPUT http://localhost:9200/pictures/ -d '
{
"settings": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "standard",
@clintongormley
clintongormley / gist:1088986
Created July 18, 2011 09:19
Create index for partial matching of names in ElasticSearch
# First, create the synonyms file /opt/elasticsearch/name_synonyms.txt
# with the contents:
#
# rob,bob => robert
#
## CREATE THE INDEX WITH ANALYZERS AND MAPPINGS
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
@karussell
karussell / backup.sh
Created July 10, 2011 20:05
Backup ElasticSearch with rsync
# TO_FOLDER=/something
# FROM=/your-es-installation
DATE=`date +%Y-%m-%d_%H-%M`
TO=$TO_FOLDER/$DATE/
echo "rsync from $FROM to $TO"
# the first times rsync can take a bit long - do not disable flusing
rsync -a $FROM $TO
# now disable flushing and do one manual flushing
@karmi
karmi / tagcloud.sh
Last active September 4, 2017 02:01
Simple tag cloud with ElasticSearch `terms` facet
# (Re)create the index
curl -X DELETE "http://localhost:9200/tagcloud"
curl -X PUT "http://localhost:9200/tagcloud"-d '{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
}
}
}'
curl -XPUT localhost:9200/local -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"stem" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stop", "porter_stem"]
}
}
}
anonymous
anonymous / gist:853994
Created March 4, 2011 01:36
# curl -XDELETE http://localhost:9200/test-index
# "analyzer"."default" => default name for index and search
# "tokenizer" : "standard" => splits words at punctuation characters
# http://www.elasticsearch.org/guide/reference/index-modules/analysis/
curl -XPUT http://localhost:9200/test-index/ -d '
{
"index": {
"analysis": {
anonymous
anonymous / gist:851600
Created March 2, 2011 19:50
curl -XPUT http://localhost:9200/test_index/ -d '
{
"index": {
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer": "nGram",
"filter": ["lowercase", "snowball"]
},