Skip to content

Instantly share code, notes, and snippets.

@stratawing
stratawing / gist:2019391
Created March 12, 2012 02:43
ES question
# mappings and analyzer below
curl -XPUT http://localhost:9200/cerberus -d '{
"mappings" : {
"rawcrit" : {
"properties" : {
....snip....
"std_par":{"type" : "string", "index_analyzer":"std_par"}
}
}
@stratawing
stratawing / ES Beginner's PHP Script
Created March 4, 2012 16:17
ES Beginner's PHP Script
<?php
$ch = curl_init();
$method = "GET";
$url = "localhost/cerberus/resraw/_search?pretty=true";
$qry = '{
"size" : 10,
"fields" : "usr",
"query" : {
@stratawing
stratawing / XLSX to ES
Created February 13, 2012 21:27
Command Line Script to bulk load XLSX into ES
unzip -Uo 10k_records.xlsx xl/worksheets/sheet1.xml xl/sharedStrings.xml -d proc
cat proc/xl/sharedStrings.xml \
| sed -e 's/[^[:print:][:blank:][:space:]]/[?]/g' -e 's/|/-delim-/g' \
| mawk 'BEGIN {RS = "</t></si><si><t>|<si><t>|</t></si></sst>|</t></si><si><t xml:space=\"preserve\">"
FS = "999ABCDE"
OFS = "|"}
{ print NR - 2, $1 }' \
| LANG=C sort -f -t "|" -k1 \
| grep -v "<sst xmlns=\|<?xml version" \