Created
May 22, 2013 09:51
-
-
Save jumski/5626464 to your computer and use it in GitHub Desktop.
elasticsearch ngram config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Author < ActiveRecord::Base | |
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
include TireHelpers | |
has_many :books | |
validates :name, presence: true | |
normalize_attributes :name | |
settings analysis: { | |
analyzer: { | |
filter: { | |
name_ngram: { | |
# type: "nGram", | |
type: "edgeNGram", | |
side: "front", | |
max_gram: 10, | |
min_gram: 1 | |
} | |
}, | |
analyzer: { | |
name_analyzer: { | |
tokenizer: "lowercase", | |
filter: ["stop", "name_ngram"] | |
} | |
} | |
} | |
} | |
mapping do | |
indexes :name, type: :string, analyzer: :name_analyzer | |
end | |
def to_indexed_json | |
AuthorSerializer.new(self).to_json | |
end | |
end |
troszok
commented
May 22, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment