Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active December 24, 2015 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/6825716 to your computer and use it in GitHub Desktop.
Save cmilfont/6825716 to your computer and use it in GitHub Desktop.
Tire.index('techniques') do
delete
create \
settings: {
index: {
:analysis => {
:analyzer=> {
:index_analyzer=> {
:tokenizer=> "standard",
:filter=> ["standard", "my_delimiter", "lowercase", "stop", "asciifolding", "porter_stem"]
},
:search_analyzer=> {
:tokenizer=> "standard",
:filter=> ["standard", "lowercase", "stop", "asciifolding", "porter_stem"]
}
},
:filter=> {
:my_delimiter=> {
:type=> "word_delimiter",
:generate_word_parts=> true,
:catenate_words=> true,
:catenate_numbers=> true,
:catenate_all=> true,
:split_on_case_change=> true,
:preserve_original=> true,
:split_on_numerics=> true,
:stem_english_possessive=> true
}
}
}
},
},
mappings: {
technique: {
properties: {
name: {
type: 'string',
boost: 10.0,
index: "analyzed",
index_analyzer: "index_analyzer",
search_analyzer: "search_analyzer",
store: "yes"
}
}
}
}
end
class Technique < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
settings( {
:analysis => {
:analyzer=> {
:index_analyzer=> {
:tokenizer=> "standard",
:filter=> ["standard", "my_delimiter", "lowercase", "stop", "asciifolding", "porter_stem"]
},
:search_analyzer=> {
:tokenizer=> "standard",
:filter=> ["standard", "lowercase", "stop", "asciifolding", "porter_stem"]
}
},
:filter=> {
:my_delimiter=> {
:type=> "word_delimiter",
:generate_word_parts=> true,
:catenate_words=> true,
:catenate_numbers=> true,
:catenate_all=> true,
:split_on_case_change=> true,
:preserve_original=> true,
:split_on_numerics=> true,
:stem_english_possessive=> true
}
}
}
}) do
mapping do
indexes :name,
:type => 'string',
:boost => 100,
:index => "analyzed",
:index_analyzer => "index_analyzer",
:search_analyzer => "search_analyzer",
:store => "yes"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment