我使用 cakephp-elasticsearch 插件来索引和搜索 mysql Db。我按照此链接中的教程进行操作:
https://github.com/dkullmann/CakePHP-Elastic-Search-DataSource
我创建了“详细信息”模块:
<?php
class details extends AppModel {
public $useDbConfig = 'index';
public $useType = 'details';
public $_mapping = array(
'name' => array('type' => 'string'),
'addr' => array('type' => 'string'),
'phno' => array('type' => 'string'),
'city' => array('type' => 'string'),
'state' => array('type' => 'string'),
);
public function elasticMapping() {
return $this->_mapping;
}
}
?>
要开始索引记录,我使用了这个命令:
Console/cake Elastic.elastic index details
我收到以下错误:
Retrieving data from mysql starting on 1970-01-01 00:00:00
Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'details.id' in 'field list'
#0 /var/www/cakephp/lib/Cake/Model/Datasource/DboSource.php(460): PDOStatement->execute(Array)
#1 /var/www/cakephp/lib/Cake/Model/Datasource/DboSource.php(426): DboSource->_execute('SELECT `details...', Array)
#2 /var/www/cakephp/lib/Cake/Model/Datasource/DboSource.php(669): DboSource->execute('SELECT `details...', Array, Array)
#3 /var/www/cakephp/lib/Cake/Model/Datasource/DboSource.php(1080): DboSource->fetchAll('SELECT `details...', false)
#4 /var/www/cakephp/lib/Cake/Model/Model.php(2696): DboSource->read(Object(details), Array)
#5 /var/www/cakephp/app/Plugin/Elastic/Console/Command/ElasticShell.php(288): Model->find('all', Array)
#6 /var/www/cakephp/lib/Cake/Console/Shell.php(389): ElasticShell->index()
#7 /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php(200): Shell->runCommand('index', Array)
#8 /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php(68): ShellDispatcher->dispatch()
#9 /var/www/cakephp/app/Console/cake.php(37): ShellDispatcher::run(Array)
#10 {main}
我没有任何名为 id 的字段。我会犯什么错误?请帮我!!