Skip to content

Instantly share code, notes, and snippets.

View matthuhiggins's full-sized avatar

Matthew Higgins matthuhiggins

View GitHub Profile
@matthuhiggins
matthuhiggins / gist:16b5d29c2ea0bb4a9e21f64268b6865f
Last active July 30, 2019 17:19
Multiple tokens in a synonym analyzer within a multiplexer
curl -X DELETE "localhost:9200/companies"
curl -X PUT "localhost:9200/companies" -H 'Content-Type: application/json' -d'
{
"settings": {
"analysis": {
"analyzer": {
"company_name_analyzer": {
"type": "custom",
"tokenizer": "standard",
curl -X DELETE "localhost:9200/companies"
curl -X PUT "localhost:9200/companies" -H 'Content-Type: application/json' -d'
{
"settings": {
"analysis": {
"analyzer": {
"company_name_analyzer": {
"type": "custom",
"tokenizer": "standard",
curl -XDELETE 'localhost:9200/my-index?pretty'
curl -XPUT 'localhost:9200/my-index?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"doc": {
"properties": {
"message": {
"type": "text"
},
PROPER_NOUN_INDEX = {
"analysis" => {
"char_filter" => {
"proper_noun_char_filter" => {
"type" => "mapping",
"mappings" => ["'\''=>", "&=>_", "-=>_"]
}
},
"analyzer" => {
"proper_noun" => {
@matthuhiggins
matthuhiggins / rpry
Last active December 28, 2015 10:39 — forked from doitian/README.md
#!/usr/bin/env ruby
require 'rubygems'
require 'pry'
if ARGV.first && !ARGV.first.index("-") && env = ARGV.shift
ENV['RAILS_ENV'] = %w(production development test).detect {|e| e =~ /^#{env}/} || env
end
ARGV.unshift "console"
@matthuhiggins
matthuhiggins / gist:6644826
Created September 20, 2013 22:33
nested mapping fields with the same name as the parent are not searchable
curl -XDELETE 127.0.0.1:9200/blog/
curl -XPOST 127.0.0.1:9200/blog/
# An article has a "title" field. Article has a nested mapping of comments, which has the fields "author" and "title".
curl -XPUT 127.0.0.1:9200/blog/article/_mapping -d '
{
"article": {
"properties":{
"title": {
"type": "string",
module ActiveModel
module Typecasting
extend ActiveSupport::Concern
#
# class PoopFactory
# include ActiveModel::Model
# include ActiveModel::Typecasting
#
# typecast_accessor :color, type: :string
@matthuhiggins
matthuhiggins / bad.rb
Created June 11, 2013 19:19
ElasticSearch scroll responses
{
"_scroll_id"=>"c2NhbjsxOzc4NjprWFFSS01qU1JOYXVmZ3MxN0dYQVVROzE7dG90YWxfaGl0czozOw==",
"took"=>2,
"timed_out"=>false,
"_shards"=>{
"total"=>5,
"successful"=>2,
"failed"=>3,
"failures"=>[
{"status"=>500, "reason"=>"SearchContextMissingException[No search context found for id [784]]"}, {"status"=>500, "reason"=>"SearchContextMissingException[No search context found for id [787]]"},
@matthuhiggins
matthuhiggins / Gunfile
Created May 11, 2013 22:27
Hello World, Gunner
p "Hello world"
@matthuhiggins
matthuhiggins / setup_teardown.rb
Created June 12, 2012 22:37
test time tracker
@@test_classes = {}
@@test_methods = {}
setup do
@start_time = Time.now
end
teardown do
delta = Time.now - @start_time