2013-02-03 36 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