Skip to content

Instantly share code, notes, and snippets.

View juneym's full-sized avatar

Raul Martinez Jr juneym

  • Carparts.com Inc
  • Torrance, CA
  • 15:07 (UTC -08:00)
View GitHub Profile
@juneym
juneym / percolated-twitter.rb
Created June 24, 2011 12:57 — forked from karmi/percolated-twitter.rb
Reversed or “Real Time” Search in ElasticSearch
# Reversed or “Real Time” Search in ElasticSearch
# ====================================================================================
# You may have come across the term “realtime search” lately
# (eg. [here](http://engineering.socialcast.com/2011/05/realtime-search-solr-vs-elasticsearch/))
# and wondered what all the fuss is about.
#
# Well, the usual workflow with search engines goes like this:
#
# 1. You index some documents.
@juneym
juneym / fuzzylikethis
Created July 5, 2011 17:52
ElasticSearch's fuzzylikethis not highlighting..
{
"query": {
"fuzzy_like_this": {
"fields": [
"title",
"content",
"tags"
],
"boost": 1.5,
"like_text": "floats",
@juneym
juneym / gist:1065424
Created July 5, 2011 17:56
highlighting works when "query_string" is used.
{
"query": {
"query_string": {
"query": "floats lsa light"
}
},
"fields": [
"dtmPosted",
"postedBy",
"url",
@juneym
juneym / elasticsearch.yml
Created July 6, 2011 16:32 — forked from arielamato/elasticsearch.yml
Cluster configuration file
cloud:
aws:
access_key: AWS_ACCESS_KEY
secret_key: AWS_SECRET_KEY
region: eu-west-1
discovery:
type: ec2
ec2:
groups: datastore-elasticsearch
# 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": {
@juneym
juneym / elasticsearch.yml
Created July 8, 2011 00:30
custom analyzer nGram
index:
refresh_interval: 2
analysis:
analyzer:
ascAnalyzer1:
type: custom
tokenizer: "standard"
@juneym
juneym / date-range-facets.sample.json
Created July 14, 2011 18:22
Sample Date Facet Range that can be used for showing facet label like: 30 minutes ago, 1 hour ago etc.
{
"query": {
"match_all": {}
},
"facets": {
"dtmPosted": {
"range": {
"key_script": "doc['dtmPosted'].date.getMillis()",
@juneym
juneym / Overview.txt
Created July 15, 2011 01:21
Task Object, Coordination & Chain of Responsibility Design pattern
Overview:
This was an example I have given to my co-developer who was doing some Task/Coodinator type of code. Hope this is helpful to many other developers out there.
Note that the example only supports one-to-one dependency between TaskObject instance. The TaskAbstract class can be easily modified to support 1-to-many dependency.
For simpicity, I have combined all three classes in this single gist:
1. TaskAbstract
2. TaskObject (extends TaskAbstract)
3. TaskCoordinator (extends TaskAbstract)
@juneym
juneym / backup.sh
Created December 4, 2011 03:34 — forked from karussell/backup.sh
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
@juneym
juneym / hack.sh
Created April 7, 2012 12:24 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#