elasticsearch,Mysql,Cakephp,elasticsearch" /> elasticsearch,Mysql,Cakephp,elasticsearch" />

Mysql 错误:SQLSTATE[42S22]:未找到列:1054未知列';详细信息。id';在';字段列表';

Mysql 错误:SQLSTATE[42S22]:未找到列:1054未知列';详细信息。id';在';字段列表';,mysql,cakephp,elasticsearch,Mysql,Cakephp,elasticsearch,我使用cakephp elasticsearch插件来索引和搜索mysql数据库。我通过以下链接阅读了教程: https://github.com/dkullmann/CakePHP-Elastic-Search-DataSource 我已经创建了“详细信息”模块: 我收到以下错误: Retrieving data from mysql starting on 1970-01-01 00:00:00 Error: SQLSTATE[42S22]: Column not found: 1054

我使用cakephp elasticsearch插件来索引和搜索mysql数据库。我通过以下链接阅读了教程:

https://github.com/dkullmann/CakePHP-Elastic-Search-DataSource
我已经创建了“详细信息”模块:

我收到以下错误:

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的字段。。我会犯什么错误?请帮帮我

所有数据库表都需要主键 默认情况下,该字段的名称为
id
。如果表具有不同的主键,则需要设置属性,以便Cake知道它是什么:

class MyModel extends AppModel {

    $primaryKey = 'odd';

}
循规蹈矩 我会犯什么错误

问题中的守则还有其他错误,即:

型号名称为单数 所以,
类详细信息
->
类详细信息

Cake在查找要使用的表时自动使用复数下划线形式(
详细信息

类名称被备份 所以
类详细信息
->
类详细信息

这本书中有更多关于这方面的信息

这一点在文档中也得到了隐式的加强,比较问题中的cli调用:

Console/cake Elastic.elastic index details
                                   ^ lower case plural model name
使用ES插件自述文件中的一个:

Console/cake Elastic.elastic index Contact
                                   ^ Correct case and singular

不遵守惯例是发现不一致行为的一种简单方法。

非常感谢。我按照你的指示做了更改。但是当我运行这个命令Console/cake Elastic.Elastic index Detail时,我得到了以下错误:error:SQLSTATE[42S22]:Column not found:1054 Unknown Column'Detail.modified'in'where子句'
默认情况下IndexableBehavior将声明您的“modified”字段作为跟踪每个记录更新或创建时间的字段,以便与ElasticSearch同步。
我建议阅读自述;)。祝你好运
Console/cake Elastic.elastic index details
                                   ^ lower case plural model name
Console/cake Elastic.elastic index Contact
                                   ^ Correct case and singular