0

I use FOQElasticaBundle to integrate Elastic Search into my Symfony2 project. I have an entity called Recipe, this entity has property $draft that indicates that the recipe is not complete yet. I want to exclude recipes that has the property $draft = 1 from Elastic Search results.

This is part of my foq_elastica configuration:

...
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: ~
....

Any suggestion?

4

1 回答 1

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: ~

并在返回一个 Doctrine Query Builder 的存储库中实现指定的方法。捆绑包的官方文档中的更多信息:https ://github.com/Exercise/FOQElasticaBundle

于 2013-10-09T15:11:34.957 回答