【问题标题】:How to set 'refresh' parameter to 'true' while indexing documents when using FOSElasticaBundle?使用 FOSElasticaBundle 索引文档时如何将“刷新”参数设置为“真”?
【发布时间】:2019-05-06 18:54:55
【问题描述】:

在将 FOSElasticaBundle 与 Symfony 框架一起使用时,如何为文档索引设置 'refresh=true' 参数?我们需要立即在搜索结果中看到更新的文档,如doc here中所述

REST 示例:

curl -XPUT 'http://localhost:9200/{index}/{type}/{id}?refresh=true' -d '{
  "property" : "value"
}'

【问题讨论】:

    标签: symfony elasticsearch foselasticabundle


    【解决方案1】:

    您需要的是官方 FOSElasticaBundle 文档而不是 ELASTICA 文档。这是文档:https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/types.md

    看看监听器部分:

    persistence:
                        listener:
                            insert: true
                            update: false
                            delete: true
    

    但请注意,您将需要更多的 CPU/RAM 资源,因为每次您将持久化由 ElasticSearch 索引的实体,ElasticSearch 将对新更新的实体执行索引。

    有关在 Symfony2 中集成 foselasticabundle 和 elasticSeach 的精彩教程,您可以在这里查看:

    http://obtao.com/blog/2014/02/indexing-and-simple-search-with-elasticsearch-and-symfony/

    【讨论】:

    • 这不是我的意思。问题不在于 Elastica,而在于 ES 本身,它在索引文档和搜索结果可用性之间增加了 1 秒(默认值)。当我更新文档并想立即在视图中查看它时,这会产生问题。这个刷新参数解决了这个问题。 elastic.co/guide/en/elasticsearch/reference/current/…
    猜你喜欢
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多