2012-05-30 6 views
5

타이어를 통해 신축성이있는 프로젝트를 상속 받고 있습니다.탄성 찾기와 타이어를 사용하여 액센트를 무시하십시오.

검색 기능은 작동하지만 액센트가 적용됩니다. "this"를 검색하면 예를 들어 "thís"와 "thiš"을 반환해야합니다. 나는이 타이어 문서를 읽고

:

뿐만 아니라 http://karmi.github.com/tire/ : http://railscasts.com/episodes/306-elasticsearch-part-1?view=asciicast 탄성 검색의 옵션의 대부분은 타이어에서 사용할 수 있음을 언급

.

는 무시 악센트에 대해 asciifolding이오고 계속 검색,하지만 탄성 검색 그냥이 그것에 대해 말을했다 :

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

이 또한 내가 이들과 같은 등 필터/악센트/대한 몇 가지 발견 :

https://gist.github.com/2142635

https://github.com/elasticsearch/elasticsearch/issues/890
그러나 그들은 모두 사용 베어 탄성 검색 옵션입니다.

내 루비 코드에서 asciifolding 필터를 사용하려고하면 "asciifolding"에 대해 정의 된 필터에 대한 오류가 발생합니다.

다음은 내 코드에서 수행되는 검색 방법입니다.이 방법을 사용하여 악센트가없는 검색을 수행하려면 어떻게해야합니까? 그것은 asciifolding인가요, 그렇다면 여기 어떻게 선언합니까?

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 

편집 : 아니면 매핑/색인 생성에서 수행해야합니까? 그런 다음 인덱서를 다시 실행하십시오. 필터 => "asciifolding을"인덱스의 일부,하지만 (오류 출력도 생성) 작동하지 않았다 : 다음은 매핑, 난 퍼팅 시도했다

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 

답변

3

가 아주 좋은 예있다 이 기사의 "asciifolding"(텍스트 색인 생성시 토큰에서 악센트 제거)은 Autocomplete with Tire

입니다.
관련 문제