Cakephp 3上的Elasticsearch实现

时间:2018-06-22 10:42:46

标签: elasticsearch cakephp-3.0

我能够在cakephp 3上合并elasticsearch,但是我失去了保存到数据库中的能力。控制器上的add方法创建索引而不是同时创建索引(保存到表并在elasticsearch中创建索引)。遵循了此处的说明-https://book.cakephp.org/3.0/en/elasticsearch.html

关于如何实现上述目标的任何想法吗?

谢谢。

从类别控制器添加代码。

public function add()
{
    $category = $this->Categories->newEntity();
    if ($this->request->is('post')) {
        $category = $this->Categories->patchEntity($category, $this->request->getData());
        if ($this->Categories->save($category)) {
            $this->Flash->success(__('The category has been saved.'));

            return $this->redirect(['action' => 'index']);
        }
        $this->Flash->error(__('The category could not be saved. Please, try again.'));
    }
    $this->set(compact('category'));
    $this->set('_serialize', ['category']);
}

0 个答案:

没有答案