Skip to content

Instantly share code, notes, and snippets.

View ianAndrewClark's full-sized avatar

Ian Clark ianAndrewClark

View GitHub Profile
@IcyMidnight
IcyMidnight / MySQL functions to convert between binary and string uuids
Created July 31, 2009 09:27
MySQL functions to convert between binary and string uuids
DELIMITER |
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
END
|
@brianleroux
brianleroux / get.js
Created November 22, 2009 06:12
Lawnchair example usage
// Get that document
people.get(me.key, function(r){
console.log(r);
});
// Returns all documents as an array to a callback
people.all(function(r){
console.log(r);
});
@brianleroux
brianleroux / lawnchair-examples.js
Created January 27, 2011 06:32
examples for using lawnchair js
// create a new store
var store = new Lawnchair({adaptor:'dom', table:'people'});
// saving documents
store.save({name:'brian'});
// optionally pass a key
store.save({key:'config', settings:{color:'blue'}});
// updating a document in place is the same syntax
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"]
},
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": {
curl -XPUT localhost:9200/local -d '{
"settings" : {
"analysis" : {
"analyzer" : {
"stem" : {
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stop", "porter_stem"]
}
}
}
@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
}
}
}'
@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
@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 '
{
@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",