Skip to content

Instantly share code, notes, and snippets.

View edwardsmit's full-sized avatar

Edward Smit edwardsmit

View GitHub Profile

Keybase proof

I hereby claim:

  • I am edwardsmit on github.
  • I am edwardsmit (https://keybase.io/edwardsmit) on keybase.
  • I have a public key ASDylFFjarZSEVkKcxcujwwmaBfMpnCR7LmHTjwVifwtYwo

To claim this, I am signing this object:

{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"rules": [
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/maptest'
curl -XPOST 'localhost:9200/maptest/_refresh?pretty'
curl -XPUT 'localhost:9200/maptest?pretty' -H 'Content-Type: application/json' -d'
{
"settings": {
"index": {
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification'; echo
curl -XPUT 'localhost:9200/nowverification/event/_mapping' -d '{
"event": {
"properties": {
"timestamp": {
"type": "date"
}
#!/usr/bin/env bash
set -e
CURRENT_DIR_OLD=$(dirname "${BASH_SOURCE[0]}" )
CURRENT_DIR_NEW=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
echo "$CURRENT_DIR_OLD"
echo "$CURRENT_DIR_NEW"
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/timeaggregate'; echo
curl -XPUT 'localhost:9200/timeaggregate'; echo
curl -XPUT 'localhost:9200/timeaggregate/event/_mapping' -d '{
"event": {
"properties": {
"timestamp": {
"type": "date"
}
@edwardsmit
edwardsmit / highlightproblem.sh
Last active September 23, 2015 13:32
Elasticsearch: no_match_size not obeyed using the fvh
#!/usr/bin/env bash
curl -XDELETE 'localhost:9200/highlightproblem'; echo
curl -XPUT 'localhost:9200/highlightproblem'; echo
curl -XPUT 'localhost:9200/highlightproblem/highlightproblem/_mapping' -d '{
"highlightproblem": {
"properties": {
"title": {
"type": "string",
"term_vector": "with_positions_offsets"
#!/usr/bin/env bash
CURRENTDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
hash foo 2>/dev/null || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; }
@edwardsmit
edwardsmit / gist:fcfbc9ed4ab3547f2020
Last active August 29, 2015 14:01
Elasticsearch MVEL score calculation: Multiply when field is present
curl -XPUT localhost:9200/test
curl -XPUT localhost:9200/test/mock/_mapping -d '{mock: {properties: {x: {type: "integer"},y: {type: "integer"}}}}'
curl -XPUT localhost:9200/test/mock/1 -d '{x:5, y:6}'
# Score should be 30
curl 'localhost:9200/test/mock/_search' -d '{query: {function_score: {query: {match_all:{}},functions: [{"script_score": {script: "doc[\"x\"].value * (doc.containsKey(\"y\") ? doc[\"y\"].value : 1)"}}]}}}'
# Score should be 5
curl 'localhost:9200/test/mock/_search' -d '{query: {function_score: {query: {match_all:{}},functions: [{"script_score": {script: "doc[\"x\"].value * (doc.containsKey(\"z\") ? doc[\"z\"].value : 1)"}}]}}}'
@edwardsmit
edwardsmit / gist:11365242
Created April 28, 2014 08:18
Using the NodeJS equivalent of eval to help in selecting the contents of properties within nested objects, using 'dot-notation'
var sandbox = {};
require('vm').runInNewContext('x["dot.notated"]', {x: {'dot.notated':'hello'}});