Skip to content

Instantly share code, notes, and snippets.

@gree2
gree2 / elasticsearch-term-frequency.sh
Created June 23, 2017 09:19 — forked from nz/elasticsearch-term-frequency.sh
In Elasticsearch, how do I get a list of the top 10 most frequently occurring values of a field?
#!/bin/sh
test_document="{
\"text\": \"HEAR the sledges with the bells, / Silver bells! / What a world of merriment their melody foretells! / How they tinkle, tinkle, tinkle, / In the icy air of night! / While the stars, that oversprinkle / All the heavens, seem to twinkle / With a crystalline delight; / Keeping time, time, time, / In a sort of Runic rhyme, / To the tintinnabulation that so musically wells / From the bells, bells, bells, bells, / Bells, bells, bells— / From the jingling and the tinkling of the bells.\"
}"
if curl -fs -X HEAD localhost:9200/top-terms; then
echo "Clear the old test index"
curl -X DELETE localhost:9200/top-terms; echo "\n"
fi
@gree2
gree2 / setup
Last active August 29, 2015 14:22 — forked from tariqmislam/setup
##########
# For verification, you can display the OS release.
##########
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10"
##########
@gree2
gree2 / SuperPomMarven2.1.txt
Created August 11, 2012 08:17
Super POM: Marven 2.1
<project>
<modelVersion>4.0.0</modelVersion>
<name>Maven Default Project</name>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
@gree2
gree2 / SuperPomMaven2.0.txt
Created August 11, 2012 08:13
Super POM: Maven 2.0
<project>
<modelVersion>4.0.0</modelVersion>
<name>Maven Default Project</name>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
@gree2
gree2 / conf-multi-node.txt
Created August 5, 2012 15:27
Install Hadoop: conf-multi-node
<!-- In: conf/core-site.xml -->
<property>
<name>fs.default.name</name>
<value>hdfs://master:54310</value>
<description>...</description>
</property>
<!-- In: conf/mapred-site.xml -->
<property>
@gree2
gree2 / conf-single-node.txt
Created August 5, 2012 15:26
Install Hadoop: conf-single-node
#Add to the end of the ~/.bashrc
# Set Hadoop-related environment variables
export HADOOP_HOME=/usr/local/hadoop
# Set JAVA_HOME (we will also configure JAVA_HOME directly for Hadoop later on)
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
# Some convenient aliases and functions for running Hadoop-related commands
unalias fs &> /dev/null
alias fs="hadoop fs"
unalias hls &> /dev/null
alias hls="fs -ls"
@gree2
gree2 / CmpMssqlDb.py
Created August 3, 2012 04:35
Python: CmpMssqlDb
import sqlite3
import pymssql
db1Conn = ['127.0.0.1', 'sa', 'sa','AuditDataCenter']
db2Conn = ['127.0.0.1', 'sa', 'sa','AuditDataCenter1']
sql = "SELECT * from INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'"
def MssqlTables(dbConn):
conn = pymssql.connect(host=dbConn[0], user=dbConn[1], password=dbConn[2], database=dbConn[3])
@gree2
gree2 / PPMConverter.py
Created August 3, 2012 03:09
Python: PPMConverter
import os, sys
import Image
ppmDir = "ppm/"
jpfDir = "jpg/"
for filename in os.listdir(ppmDir):
(name, ext) = os.path.splitext(filename)
if ".ppm" != ext:
continue
@gree2
gree2 / Convert2Xaml.py
Created August 3, 2012 03:07
Python: Convert2Xaml
import re
import os
from lxml import etree
from copy import deepcopy
fileInput = "Input.xml"
fileOutput = "Output.xml"
def Indent(elem, level=0):
i = "\n" + level * " "