-1
使用cakephp-elasticsearch插件來索引和搜索mysql Db。我跟着從這個鏈接教程:錯誤:SQLSTATE [42S22]:未找到列:1054'字段列表'中的未知列'details.id'
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的字段..我會做什麼錯誤?請幫幫我!!
非常感謝。我根據您的指示進行了更改。但是當我運行這個命令控制檯/蛋糕Elastic.elastic索引詳細信息我得到以下錯誤:錯誤:SQLSTATE [42S22]:未找到列:1054未知列'在'子句中'Detail.modified' –
'默認情況下IndexableBehavior將聲明您的「修改」字段作爲跟蹤何時更新或創建每條記錄以便與ElasticSearch同步的字段。「我建議閱讀自述文件;)。祝你好運。 – AD7six