【问题标题】:Ruby-Tire wait for indexes to get createdRuby-Tire 等待创建索引
【发布时间】:2015-06-19 01:03:51
【问题描述】:

使用Tire,我需要在创建一些记录后在测试用例中填写索引,我就是这样做的。

['London', 'Mumbai', 'New York'].each { |name| Place.create(name: name) }
t = Tire.index('places')
t.import(Place.all.entries)

在继续之前如何等待创建索引?

【问题讨论】:

  • 你是在暗示Tire.index 是异步的吗?
  • 您可以根据自述文件将它们放入块中。像这样的东西应该可以Tire.index 'places' { import Place.all }
  • @MikeSlutsky 是的,我认为Tire.import 是异步的,有时会在没有结果后立即搜索...
  • @engineersmnky 谢谢,我会试试你的建议
  • 你试过导入后直接调用t.refresh吗?您的 elasticsearch 索引可能已完全更新,但 Tire 与它不同步。

标签: ruby-on-rails ruby elasticsearch tire


【解决方案1】:

拨打import后直接拨打t.refresh。这将确保 Tire 与 elasticsearch 同步。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-04
    • 1970-01-01
    相关资源
    最近更新 更多