2013-02-03 37 views
1

我用Symfony2創建了一個使用Doctrine2的(Gedmo)可翻譯行爲擴展的多語言網站。這工作正常,但現在我正在尋找一種方法來使用ElasticaBundle創建一個不錯的searchoption。我希望德國用戶在德語翻譯中進行搜索,但也要在英文翻譯中進行搜索。通過使用ElasticaBundle和可翻譯的多語言記錄進行搜索

此刻,我試圖爲每種語言使用單獨的索引。我config.yml看起來是這樣的:

foq_elastica:  
    clients: 
     default: { host: localhost, port: 9200 }  
    indexes:     
     articles_en: 
      client:default                     
      types: 
       article: 
       mappings: 
        name: { boost: 5, analyzer: my_analyzer }                   
       persistence: 
        driver: orm 
        model: Test\SiteBundle\Entity\Article 
        identifier: id 
        provider: 
         service: elastica.translation.provider.article.en       
        finder: 
     articles_de: 
     .... 
     articles_nl: 
     ..... 

,如果你想通過一個索引搜索,但搜索兩個指標似乎不可能與此軟件包或我錯了也能正常工作?

有沒有辦法做到這一點?任何幫助將不勝感激!

裏克

回答

3

你或許應該只需要添加一個索引每一種語言的每一篇文章,並添加一種語言來索引。然後,您可以使用一種或多種語言在索引中搜索文章。

+0

Thnx,我會試試這個。您的完整答案可以在https://github.com/Exercise/FOQElasticaBundle/issues/227#issuecomment-13282681 – Rick

+0

找到。但是,然後你不能爲每種語言使用不同的分析儀,我說得對嗎?唉,問題的網址實際上是https://github.com/FriendsOfSymfony/FOSElasticaBundle/issues/227#issuecomment-13282681 – xPheRe