View lunr.contraction_filter.js
lunr.contractionTrimmer = function (token) {
return token.replace(/('ve|n't|'d|'ll|'ve|'s|'re)$/, "")
}
lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'contractionTrimmer')
var englishContractions = function (idx) {
idx.pipeline.after(lunr.trimmer, lunr.contractionTrimmer)
}
View set_test.rb
require 'minitest/autorun'
require 'set'
class Foo
def initialize(s)
@s = s
end
def ==(other)
@s == other
View idx.json
{"version":"2.0.0-alpha.5","averageDocumentLength":10.5,"b":0.75,"k1":1.2,"fields":["name","content","person"],"documentVectors":[["-KgJdlp7WdeQO16yUyMd",[0,0.25774058577405856,1,0.25774058577405856,2,0.25774058577405856,3,0.25774058577405856,4,0.9112426035502958,5,0.18224852071005918,6,0.18224852071005918,7,0.9112426035502958,8,0.9112426035502958]],["-KgJhVbn3E_r8TqMyrP3",[5,0.22158273381294966,6,0.22158273381294966,9,0.2947368421052632,10,0.2947368421052632,11,1.1079136690647482,12,1.1079136690647482]]],"invertedIndex":[["ce",{"_index":2,"name":{"-KgJdlp7WdeQO16yUyMd":{}},"content":{"-KgJdlp7WdeQO16yUyMd":{}},"person":{}}],["connard",{"_index":1,"name":{"-KgJdlp7WdeQO16yUyMd":{}},"content":{"-KgJdlp7WdeQO16yUyMd":{}},"person":{}}],["droit",{"_index":10,"name":{"-KgJhVbn3E_r8TqMyrP3":{}},"content":{"-KgJhVbn3E_r8TqMyrP3":{}},"person":{}}],["et",{"_index":11,"name":{},"content":{"-KgJhVbn3E_r8TqMyrP3":{}},"person":{}}],["jacqu",{"_index":5,"name":{},"content":{},"person":{"-KgJdlp7WdeQO16yUyMd":{},"-KgJhVbn3E
View output
'abc'
[:program,
[[:string_literal, [:string_content, [:@tstring_content, "abc", [1, 1]]]]]]
'a' 'b' 'c'
[:program,
[[:string_concat,
[:string_concat,
[:string_literal, [:string_content, [:@tstring_content, "a", [1, 1]]]],
[:string_literal, [:string_content, [:@tstring_content, "b", [1, 5]]]]],
View gist:1129339
<script src="http://raphaeljs.com/raphael.js" type="text/javascript" charset="utf-8"></script>
<style type="text/css" media="screen">
body {
background-color: black;
color: white;
font-family: helvetica;
}
#display {
View Search.md

So many of your fields look like tags or facets, e.g. sector or market, so you full text search might not be the best way to search on these.

Instead if you had full text search on the tags themselves, e.g. full text search on all the possible values for sector or market, and then, with the resuts of this tag lookup, go and find companies that have this tag. The facted search, lookup by tags (or groups of tags) isn't really lunr's forte, but you could certainly use it for full text search of the tags.

var idx = lunr(function () {
  this.ref('id')
  this.field('name')
})
  
View colors.html
<body>
<script>
var randInRange = function (min, max) {
var range = max - min
return min + (Math.random() * range)
}
var HSL = function (h, s, l) {
this.h = h, this.s = s, this.l = l
View duration.rb
class Duration
include Comparable
attr_reader :milliseconds
def initialize(value = 0)
case value
when Fixnum
@milliseconds = value
when String
View bench.rb
require 'benchmark'
words = File.open('/usr/share/dict/words', 'r') do |file|
file.each_line.take(100_000).map(&:chomp)
end
Benchmark.bmbm(20) do |x|
GC.start
x.report("map") do
words.map do |word|
View dev_logs.conf
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/path/to/log/*.log 644 0 5120 * GN