【问题标题】:Algolia Restrict Index's dataAlgolia Restrict Index 的数据
【发布时间】:2016-08-04 16:50:17
【问题描述】:

我正在尝试在 Algolia 中创建一个新索引,该索引与我的第一个索引相同,但数据与我的第一个索引不同。我想要一个新西兰联系人索引和一个澳大利亚联系人索引。

我在这个函数中使用了indexOnly($index_name) 和一个条件。但是它不能正常工作,我不知道这个功能是不是我需要的。

这就是我的创作方式

class Contact extends Model {

  use AlgoliaEloquentTrait;

  protected $table = 'contacts';

  public $indices = ['contacts_local'];

  /** ALGOLIA SETTINGS */

  public function getAlgoliaRecord()
  {
    return fractal()->item($this)->transformWith(new ContactTransformer)->toArray();
  }

  private $index_name = 'contacts_local';

  public function indexOnly($index_name) {
    return $this->contact_country == 'New Zealand';
  }
}

然后我运行重新索引函数。

上述方法在我的contacts_local 索引中没有返回任何内容。 我在这里做错了什么?

我在我的数据库中使用同一个表,但根据contactcountry,这两个索引会有不同的数据。这在阿尔及利亚可行吗?

【问题讨论】:

    标签: laravel algolia


    【解决方案1】:

    我不确定这对于 Algolia Laravel/Eloquent 集成是否可行。我会做的是:

    这将更容易和更快,因为每个国家/地区都有 1 个索引。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-30
      • 1970-01-01
      • 2014-01-04
      • 1970-01-01
      • 2022-01-17
      • 2023-03-26
      • 1970-01-01
      • 2020-12-31
      相关资源
      最近更新 更多