想把自己的部落格用上 Elasticsearch 搜尋,用的是 Yii2-elasticsearch 擴充
搞了半天不會用,沒搞明白 elasticsearch 是個怎麼回事,是要把 Mysql 中的資料弄到 ES 中去嗎?
難道每次都要到msql中去把資料找出來,再一個一個賦值給 ES 嗎?
$posts = Post::find()->all();$postElastic = new PostElastic();$postElastic->attributes = ['name' => $postElastic[0]->name];
要像上面這樣嘛?那也太蛋疼了吧
但是直接 Contents::find()->all()
查出來的也沒有資料,
class Contents extends \yii\elasticsearch\ActiveRecord{ public function attributes() { return ['id', 'title', 'slug', 'created_at', 'text', 'type', 'status']; }}
回複內容:
想把自己的部落格用上 Elasticsearch 搜尋,用的是 Yii2-elasticsearch 擴充
搞了半天不會用,沒搞明白 elasticsearch 是個怎麼回事,是要把 Mysql 中的資料弄到 ES 中去嗎?
難道每次都要到msql中去把資料找出來,再一個一個賦值給 ES 嗎?
$posts = Post::find()->all();$postElastic = new PostElastic();$postElastic->attributes = ['name' => $postElastic[0]->name];
要像上面這樣嘛?那也太蛋疼了吧
但是直接 Contents::find()->all()
查出來的也沒有資料,
class Contents extends \yii\elasticsearch\ActiveRecord{ public function attributes() { return ['id', 'title', 'slug', 'created_at', 'text', 'type', 'status']; }}