Skip to content

Instantly share code, notes, and snippets.

@stimms
Forked from hohyon-ryu/ES_Stemming.rb
Created June 24, 2013 19:19
Show Gist options
  • Save stimms/5852701 to your computer and use it in GitHub Desktop.
Save stimms/5852701 to your computer and use it in GitHub Desktop.
# Script to test stemming for ElasticSearch. Working now!!
# Reference: http://stackoverflow.com/questions/4981001/why-elasticsearch-is-not-finding-my-term
require 'rubygems'
require 'net/http'
require 'yaml'
require 'json'
# kill the index
delete = Net::HTTP::Delete.new("/willindex")
# create again
create_index = Net::HTTP::Post.new("/willindex")
create_index.body = {
"index"=>
{ "number_of_shards"=> 1,
"analysis"=> {
"filter"=> {
"snowball"=> {
"type"=> "snowball",
"language"=> "English"
}
},
"analyzer"=> {
"a_stemming"=> {
"type"=>"custom",
"tokenizer"=> "standard",
"filter"=> ["lowercase", "snowball"]
}
}
}
}
}.to_yaml
puts create_index.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment