Skip to content

Instantly share code, notes, and snippets.

View matthuhiggins's full-sized avatar

Matthew Higgins matthuhiggins

View GitHub Profile
module ActiveModel
module Typecasting
extend ActiveSupport::Concern
#
# class PoopFactory
# include ActiveModel::Model
# include ActiveModel::Typecasting
#
# typecast_accessor :color, type: :string
@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",
@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"
PROPER_NOUN_INDEX = {
"analysis" => {
"char_filter" => {
"proper_noun_char_filter" => {
"type" => "mapping",
"mappings" => ["'\''=>", "&=>_", "-=>_"]
}
},
"analyzer" => {
"proper_noun" => {
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"
},
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",
@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",