Skip to content

Instantly share code, notes, and snippets.

int cursor = 0;
SearchResponse searchResponse = new SearchRequestBuilder(client)
.setIndices(alias)
.setSearchType(SearchType.SCAN)
.setQuery(matchAllQuery())
.setSize(10)
.setFrom(cursor)
.setScroll(TimeValue.timeValueMinutes(10))
.execute()
@hukl
hukl / gist:961418
Created May 8, 2011 15:15
Sample ElasticSearch session for ngram
Settings:
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"analysis" : {
"filter" : {
"edge_ngram" : {
"side" : "front",
"max_gram" : 20,
@hukl
hukl / gist:961310
Created May 8, 2011 11:10 — forked from clintongormley/gist:961303
Ngram example
###################
# CREATE THE INDEX:
###################
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d '
{
"settings" : {
"analysis" : {
"filter" : {
"edge_ngram" : {
"side" : "front",
require 'stringio'
module Munchies
class Logfile
include Enumerable
# Matches timestamps in logfile
TIME_REGEXP = /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\b/
@hukl
hukl / parser_5.rb
Created February 12, 2011 20:21
Yields the last 5 minutes of a pound log file
require 'time'
require 'stringio'
class LogfileParser
TIME_REGEXP = /\[\d{2}\/\w{3}\/\d{4}\:\d{2}:\d{2}:\d{2}\s.{5}\]/
def initialize path, starting_at
raise ArgumentError unless File.exists?( path )
require 'time'
class LogfileParser
TIME_REGEXP = /\[\d{2}\/\w{3}\/\d{4}\:\d{2}:\d{2}:\d{2}\s.{5}\]/
def initialize path, starting_at
raise ArgumentError unless File.exists?( path )
@log = File.open( path )
require 'time'
class LogfileParser
TIME_REGEXP = /\[\d{2}\/\w{3}\/\d{4}\:\d{2}:\d{2}:\d{2}\s.{5}\]/
def initialize path, starting_at
raise ArgumentError unless File.exists?( path )
@log = File.open( path )
require 'time'
class LogfileParser
# Regexp to match the timestamps in the apache common log format
TIME_REGEXP = /\[\d{2}\/\w{3}\/\d{4}\:\d{2}:\d{2}:\d{2}\s.{5}\]/
def initialize path, starting_at
raise ArgumentError unless File.exists?( path )
@hukl
hukl / parser_1.rb
Created February 12, 2011 13:08
Simple approach of parsing a large logfile
require 'time'
class LogfileParser
# Regexp to match the timestamps in the apache common log format
TIME_REGEXP = /\[\d{2}\/\w{3}\/\d{4}\:\d{2}:\d{2}:\d{2}\s.{5}\]/
def initialize path, starting_at
raise ArgumentError unless File.exists?( path )
def foo a
puts "hey" + a
end
["1","2","3"].each(&method(:foo))