Skip to content

Instantly share code, notes, and snippets.

View clintongormley's full-sized avatar

Clinton Gormley clintongormley

  • Barcelona, Spain
View GitHub Profile
@clintongormley
clintongormley / gist:864115
Created March 10, 2011 13:49
ElasticSearch - not_analyzed array
# [Thu Mar 10 14:48:46 2011] Protocol: http, Server: 127.0.0.1:9200
curl -XPUT 'http://127.0.0.1:9200/foo/' -d '
{}
'
# [Thu Mar 10 14:48:46 2011] Response:
# {
# "ok" : true,
# "acknowledged" : true
# }
@clintongormley
clintongormley / gist:867119
Created March 12, 2011 07:41
Invalid XML
my $Invalid_XML = qr/[^
\x{9}\x{A}\x{D}
\x{20}-\x{D7FF}
\x{E000}-\x{FFFD}
\x{10000}-\x{10FFFF}
]/x;
# [Sun Mar 13 19:03:04 2011] Protocol: http, Server: 127.0.0.1:9201
curl -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=1&timeout=30s&wait_for_status=green'
# [Sun Mar 13 19:03:04 2011] Response:
# {
# "number_of_data_nodes" : 3,
# "relocating_shards" : 0,
# "active_shards" : 16,
# "status" : "green",
# "cluster_name" : "es_test",
curl -XPUT 'http://127.0.0.1:9200/foo/?pretty=1' -d '
{
"mappings" : {
"item" : {
"properties" : {
"category" : {
"type" : "object",
"include_in_all" : 0,
"properties" : {
"name" : {
@clintongormley
clintongormley / gist:949602
Created April 30, 2011 11:02 — forked from monken/gist:934765
camelcase tokenizer
curl -XDELETE localhost:9200/test
curl -XPUT 'localhost:9200/test?pretty=1' -d '
{
"settings":{
"analysis": {
"analyzer": {
"camel":{
"type": "pattern",
"lowercase": true,
"pattern":"([^\\p{L}\\d]+)|(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)|(?<=[\\p{L}&&[^\\p{Lu}]])(?=\\p{Lu})|(?<=\\p{Lu})(?=\\p{Lu}[\\p{L}&&[^\\p{Lu}]])"
###################
# CREATE THE INDEX:
###################
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"analysis" : {
"filter" : {
"edge_ngram" : {
"side" : "front",
@clintongormley
clintongormley / crawl.pl
Created May 20, 2011 08:24
Crawl ElasticSearch blogposts
#!/usr/bin/perl
use strict;
use warnings;
use URI;
use Web::Scraper;
use ElasticSearch();
my $url = URI->new("http://www.elasticsearch.org/blog");
my $es = ElasticSearch->new(
@clintongormley
clintongormley / search.pl
Created May 20, 2011 08:25
Search ElasticSearch blogposts
#!/usr/bin/perl
use strict;
use warnings;
use ElasticSearch();
my $es = ElasticSearch->new(
servers => 'localhost:9200',
use_index => 'es_blogs',
use_type => 'post'
);
# [Thu Jun 2 18:14:46 2011] Protocol: http, Server: 192.168.5.103:9200
curl -XDELETE 'http://127.0.0.1:9200/twitter/?pretty=1'
# [Thu Jun 2 18:14:46 2011] Response:
# {
# "ok" : true,
# "acknowledged" : true
# }
# [Thu Jun 2 18:14:48 2011] Protocol: http, Server: 192.168.5.103:9200
@clintongormley
clintongormley / gist:1006302
Created June 3, 2011 13:06
EasyJet charges for receipts
Name: XXXXXXXXXXXXXXXX
Title: Please can you send me an invoice for the above booking, It should be addressed ...
Date: 03/06/2011
Our Reference: XXXXXXXXXXXXXX
Booking Reference: XXXXXXXXXXX
3rd June 2011
Dear Mr XXXXXXXXXXX,