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
require 'rubygems' | |
require 'rubberband' | |
index = 'foo' | |
type = 'bar' | |
searcher = ElasticSearch.new("localhost:9200", :index => index, :type => type) | |
searcher.delete_index(index) rescue nil | |
searcher.create_index index | |
searcher.index({:name => 'foo'}) | |
searcher.refresh |
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 'http://localhost:9200/foo' | |
curl -XPUT 'http://localhost:9200/foo' -d ' | |
{ | |
index: {} | |
} | |
' | |
curl -XPUT 'http://localhost:9200/foo/bar/123' -d ' | |
{ | |
name: "baz" | |
} |
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 'http://localhost:9200/foo/bar' | |
curl -XPUT 'http://localhost:9200/foo/bar/123' -d ' | |
{ | |
name: "baz" | |
} | |
' | |
curl -XPOST 'http://localhost:9200/foo/_refresh' | |
curl -XGET 'http://localhost:9200/foo/bar/_search?q=baz&size=10' |
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 -XPUT localhost:9200/_percolator/elastic_searchable/myfilter -d '{ | |
query: { | |
query_string: { | |
query: "foo" | |
} | |
} | |
}' | |
curl -XPOST localhost:9200/_percolator/_refresh | |
curl -XPUT localhost:9200/elastic_searchable/books/1?percolate=* -d '{ | |
title: "foo bar" |
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 http://localhost:9200/test | |
curl -XPUT http://localhost:9200/test -d " | |
{\"analysis.analyzer.default.tokenizer\":\"standard\",\"mappings\":{\"users\":{\"properties\":{\"name\":{\"index\":\"not_analyzed\",\"type\":\"string\"}}}},\"analysis.analyzer.default.filter\":[\"standard\",\"lowercase\",\"porterStem\"]} | |
" | |
curl http://localhost:9200/test/_status | jsonpretty |
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
#!/bin/bash | |
# error in log output | |
# [2011-04-12 17:07:03,319][DEBUG][action.admin.indices.status] [Foster, Tom] [foo][2], node[-Dbau_mxSR2TtFDAsvncyQ], [P], s[INITIALIZING]: Failed to execute [org.elasticsearch.action.admin.indices.status.IndicesStatusRequest@2a2e0135] | |
# org.elasticsearch.index.IndexShardMissingException: [foo][2] missing | |
# at org.elasticsearch.index.service.InternalIndexService.shardSafe(InternalIndexService.java:165) | |
# at org.elasticsearch.action.admin.indices.status.TransportIndicesStatusAction.shardOperation(TransportIndicesStatusAction.java:148) | |
# at org.elasticsearch.action.admin.indices.status.TransportIndicesStatusAction.shardOperation(TransportIndicesStatusAction.java:57) | |
# at org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction$AsyncBroadcastAction.performOperation(TransportBroadcastOperationAction.java:238) | |
# at org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction$AsyncBroadcastAction.access$200(TransportBroadcastOperationA |
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
{ | |
"cluster_name" : "elasticsearch", | |
"master_node" : "-Dbau_mxSR2TtFDAsvncyQ", | |
"blocks" : { | |
}, | |
"nodes" : { | |
"-Dbau_mxSR2TtFDAsvncyQ" : { | |
"name" : "Foster, Tom", | |
"transport_address" : "inet[/10.0.1.4:9300]", | |
"attributes" : { |
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
require 'jslint' | |
# "var someJsExpresion = 'stuff';".should be_lintable | |
RSpec::Matchers.define :be_lintable do |expected| | |
match do |actual| | |
tmp_js_output_dir = Rails.root.join('tmp', 'js_lintable') | |
FileUtils.mkdir_p tmp_js_output_dir unless File.exists?(tmp_js_output_dir) | |
tmp_js_output = File.join(tmp_js_output_dir, 'output.js') |
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
# add helper methods | |
class String | |
def inspect_bytes | |
index = 0 | |
self.each_byte do |b| | |
puts "#{index}: #{b} => #{b.chr}" | |
index += 1 | |
end | |
end | |
def convert_to_utf8 |
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
module ActiveRecord::ConnectionAdapters::DatabaseStatements | |
def select_all_with_explain_plan(sql, name = nil) | |
missing_indexes = select_all_without_explain_plan("EXPLAIN #{sql}", "explain plan").reject {|r| r['key'] } | |
raise "Missing dataabase indexes: #{missing_indexes.inspect}" if missing_indexes.any? | |
select_all_without_explain_plan(sql, name) | |
end | |
alias_method_chain :select_all, :explain_plan | |
end |