FosElasticaBundle: how to dump the actual JSON passed to ElasticSearch?

点点圈 提交于 2019-12-13 04:12:13

问题


I am using FosElasticaBundle in a Symfony project. I configured my mappings but I get exception "expected a simple value for field [_id] but found [START_OBJECT]]".

I'd like to see the actual JSON created by FosElasticaBundle so I can directly test it against my ElasticSearch server, and understand more about the exception.

According to FosElastica documentation, everything should be logged when debug mode is enabled (i.e. in DEV environment) but I can't see this happening; I only see Doctrine queries, but no JSON.

How can I dump the JSON created by FosElasticaBundle?

Update: mappings

# FOSElasticaBundle
fos_elastica:
    clients:
        default: { host: %elasticsearch_host%, port: %elasticsearch_port%, logger: false }
    indexes:
        app:
            types:
                user:
                    mappings:
                        name: ~
                        surname: ~
                    persistence:
                        driver: orm
                        model: AppBundle\Entity\User
                        provider: ~
                        listener: ~
                        finder: ~

回答1:


I think you should only set your logger to true instead of false

fos_elastica:
    clients:
        default:
            host: %elasticsearch_host%
            port: %elasticsearch_port%
            logger: true                        <---- set true here
    ...


来源:https://stackoverflow.com/questions/32091629/foselasticabundle-how-to-dump-the-actual-json-passed-to-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!