Skip to content

Instantly share code, notes, and snippets.

@suras
Created August 24, 2013 07:35
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 suras/6326679 to your computer and use it in GitHub Desktop.
Save suras/6326679 to your computer and use it in GitHub Desktop.
Indexing email tire
include Tire::Model::Search
include Tire::Model::Callbacks
settings :analysis =>{
:analyzer => {
:uax_url_email => {
:filter => [
"standard",
"lowercase",
"stop"
],
:tokenizer => 'uax_url_email'
}
}
} do
mapping {
indexes :email, type: 'string', index: :analyzed
indexes :exact, type: 'string', index: :not_analyzed
}
end
def self.search(params)
tire.search(load: true, page: params[:page], per_page: 50) do
query { string "email.exact:#{params[:query][0]}" } if params[:query].present?
end
end
def to_indexed_json
self.to_json
end
but not working. in fact i cant search email at all. if i did this
include Tire::Model::Search
include Tire::Model::Callbacks
settings :analysis =>{
:analyzer => {
:uax_url_email => {
:filter => [
"standard",
"lowercase",
"stop"
],
:tokenizer => 'uax_url_email'
}
}
} do
mapping {
indexes :email, type: 'string', analyzer: 'standard'
}
end
def self.search(params)
tire.search(load: true, page: params[:page], per_page: 50) do
#query { terms :email, params[:query], :minimum_match => 10} if params[:query].present?
query { string "email:#{params[:query][0]}" } if params[:query].present?
end
end
def to_indexed_json
self.to_json
end
i can search email upto test@gmail but when searching test@gmail.com (including dot(.)) no result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment