2013-10-09 79 views
0

我使用FOQElasticaBundle將Elastic Search集成到我的Symfony2項目中。我有一個名爲Recipe的實體,此實體具有屬性$draft,表明配方尚未完成。我想從彈性搜索結果中排除具有屬性$draft = 1的食譜。根據字段內容排除Elastic Search的結果

這是我foq_elastica配置的一部分:

... 
types: 
    chef: 
     mappings: 
      surname: {boost: 5} 
      name: {boost: 4} 
      nbLikes: { index: not_analyzed } 
      nbFollowers: { index: not_analyzed } 
      persistence: 
      driver: orm 
      model: Interacso\ApiBundle\Entity\Chef 
      identifier: id 
      provider: ~ 
      finder: ~ 
      listener: ~ 
    recipe: 
     mappings: 
      name: {boost: 100} 
      chefName: {boost: 10} 
      chefSurname: {boost: 10} 
      bookNames: {boost: 5} 
      ingredientNames: {boost: 2} 
      tagNames: {boost: 2} 
     persistence: 
      driver: orm 
      model: Interacso\ApiBundle\Entity\Recipe 
      identifier: id 
      provider: ~ 
      finder: ~ 
      listener: ~ 
.... 

什麼建議嗎?

回答

0

好吧,我找到了答案由我自己,如果有人有同樣的問題,反應是指定在配置文件中的查詢生成器:

recipe: 
    mappings: 
     name: {boost: 100} 
     chefName: {boost: 10} 
     chefSurname: {boost: 10} 
     bookNames: {boost: 5} 
     ingredientNames: {boost: 2} 
     tagNames: {boost: 2} 
    persistence: 
     driver: orm 
     model: Interacso\ApiBundle\Entity\Recipe 
     identifier: id 
     provider: 
       query_builder_method: buildIfIsNotDraft 
     finder: ~ 
     listener: ~ 

並實行信息庫中的指定方法返回學說查詢生成器。該軟件包的官方文檔中的更多信息:https://github.com/Exercise/FOQElasticaBundle