This example demostrates how to manipulate search results with the script_fields
support in Elasticsearch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE "localhost:9200/test" | |
curl -XPUT "localhost:9200/test" -d '{ | |
"mappings": { | |
"doc": { | |
"properties": { | |
"price": { | |
"type": "long" | |
}, | |
"colour": { | |
"type": "string", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function() { | |
var d3 = { | |
version: "3.4.11" | |
}; | |
if (!Date.now) Date.now = function() { | |
return +new Date(); | |
}; | |
var d3_arraySlice = [].slice, d3_array = function(list) { | |
return d3_arraySlice.call(list); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :default => :run | |
# Serving files via Rack | |
desc "Serve the files via Rack and Thin" | |
task :run => [:dependencies] do | |
port = ENV['PORT'] || 8000 | |
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80 | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :default => :run | |
# Serving files via Rack | |
desc "Serve the files via Rack and Thin" | |
task :run => [:dependencies] do | |
port = ENV['PORT'] || 8000 | |
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80 | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's delete the index first | |
curl -X DELETE localhost:9200/people | |
# Create an index with specific settings | |
curl -X POST localhost:9200/people -d '{ | |
"settings" : { | |
"index" : { "number_of_shards" : 1, "number_of_replicas" : 0 } | |
} | |
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# | |
# $ ruby generate.rb > people.csv | |
require 'time' | |
require 'faker' | |
require 'oj' | |
COUNT = (ENV['COUNT'] || 1000).to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "index" : { "_index" : "myindex", "_type" : "document", "_id" : "1" } } | |
{ "title" : "Jumping High" } | |
{ "index" : { "_index" : "myindex", "_type" : "document", "_id" : "2" } } | |
{ "title" : "Diving Deeper" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "http://rubygems.org/" | |
gem "sinatra", "~> 1.3.0" | |
gem "thin" |