Created
August 24, 2013 07:35
-
-
Save suras/6326679 to your computer and use it in GitHub Desktop.
Indexing email tire
This file contains 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
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