2013-06-04 6 views
1

검색을 위해 탄력적 인 검색과 타이어를 설정했습니다.타이어 검색에서 악센트를 무시하지 않습니다

내 모델에서 다음 설정이 있습니다

tire.settings :analysis => { 
    :analyzer => { 
     :spanish_snowball => { 
     :type => "snowball", 
     :language => "Spanish", 
     :filter => %w{asciifolding lowercase} 
     } 
    } 
    } 

을 그리고 다음 매핑 :

tire.mapping do 
     indexes :id, :index => :not_analyzed 
     indexes :name, :analyzer => 'spanish_snowball', :boost => 3 
     indexes :urbanization, :analyzer => 'spanish_snowball' 

     indexes :categories do 
     indexes :name, :analyzer => 'spanish_snowball' 
     end 

     indexes :tags do 
     indexes :name, :analyzer => 'spanish_snowball' 
     end 
    end 

가 나는 또한

def to_indexed_json 
    to_json include: { categories: { only: [:name]}, tags: { only: [:name]} } 
end 

내가 악센트를 무시하려는 to_indexed_json 방법을 정의를 내 검색 결과, 내에 asciifolding을 사용하고 있습니다. 10 분석기. 그러나 액센트는 무시되지 않습니다. 나는 컬 분석기를 테스트 한

Business.tire.search("japonés").size 
=> 10 

Business.tire.search("japones").size 
=> 0 

은 분석기는 당신이 말할 검색 쿼리를 분석하는 방법 elasticsearch 할 필요가 검색을 수행 할 때

➜ ~ curl -XGET 'localhost:9200/businesses/_analyze?pretty=1&text=Japonés%20nobu&analyzer=spanish_snowball' 
{ 
    "tokens" : [ { 
    "token" : "japones", 
    "start_offset" : 0, 
    "end_offset" : 7, 
    "type" : "<ALPHANUM>", 
    "position" : 1 
    }, { 
    "token" : "nobu", 
    "start_offset" : 8, 
    "end_offset" : 12, 
    "type" : "<ALPHANUM>", 
    "position" : 2 
    } ] 
}% 

답변

0

잘 동작하는 것.

짧은 형태 Model.search 'foo'하지 않습니다 (내가 생각하는) 당신은 그러나 당신이 할 수있는 더 긴 버전과 이러한 옵션을 지정할 수 있습니다 :

Model.search do 
    query do 
    string 'foo', :analyzer => 'bar' 
    end 
end 
0

당신은 너무 쿼리 분석기에 asciifolding 필터를 지정해야합니다. Frederick Cheung이 말했듯이, 쿼리를 위해 새로운 분석기를 만들거나 인덱싱을 위해 새로운 분석기를 만들어야합니다 (나는 일반적으로 인덱스 레코드를 작성하는 것과 같은 방법으로 검색 쿼리를 분류하기를 원하지 않기 때문에 전 권장합니다) .

관련 문제