Ignore accents using elastic search and tire

I am inheriting a project that has an elastic bus search.

Search works, but it emphasizes it. A search for "this" should return, for example, "th" and "thiΕ‘".

I read this tire information: http://karmi.github.com/tire/

Also like: http://railscasts.com/episodes/306-elasticsearch-part-1?view=asciicast

Which means most elastic search options are available in tires.

A search for ignoring accents, asifolding continued to grow, but an elastic search simply says this:

http://www.elasticsearch.org/guide/reference/index-modules/analysis/asciifolding-tokenfilter.html

In addition, I found several things about filters / accents / etc, for example:

https://github.com/elasticsearch/elasticsearch/issues/890
https://gist.github.com/2142635

But they all use simple search options.

When I try to use the asciifolding filter in my ruby ​​code, I get an error message for the filter defined for "asciifolding".

Here the guts of the search are executed in my code - how can I change this to perform a search using accent. This is asciifolding, and if so, how do I declare it here?

result = tire.search(:load => true,page: params[:page], per_page: params[:per_page] ) do
  query { string "#{params[:term]}", :default_operator => 'and' }  if params[:term].present?
  filter  :missing,   :field => 'original_media_id' #see above
  #asciifolding?
  sort { by :updated_at, :desc } if params[:term].present?
  facet 'files' do
    terms  'indexed_files.file.id'  
  end
end

EDIT: Or maybe this should be done when matching / indexing? And then run the indexer. Here's a comparison, I tried putting: filter => "asciifolding" on some indices, but this did not seem to work (and does not generate any errors):

tire.mapping do
    indexes :id, :index => :not_analyzed
    indexes :name, :filter => "asciifolding"
    indexes :description, :filter => "asciifolding"
    indexes :created_at, :type => 'date'
    indexes :updated_at, :type => 'date'
    indexes :file_type
    indexes :indexed_files, :type => 'object' do
        indexes :file, :type => 'object', 
            :properties => { 
            :title => {
            :type => "multi_field",
              :fields => {
                :raw => { :type => 'string', :index => 'not_analyzed'},
                :title => { :type => 'string', :filter => "asciifolding" }
              }
            },
            :description => { :type => "string", :filter => "asciifolding" }
           }
    end
end
+5
source share
1

"asciifolding" ( ) :

+3

All Articles