Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试使用带Symfony2的Solr索引文档时未找到类_Symfony_Solr_Indexing_Solarium - Fatal编程技术网

尝试使用带Symfony2的Solr索引文档时未找到类

尝试使用带Symfony2的Solr索引文档时未找到类,symfony,solr,indexing,solarium,Symfony,Solr,Indexing,Solarium,我对Solr非常陌生,我可能错过了一些简单的东西,但在完成演示后,我设置了Symfony2、Solarium和Nelmio\SolariumHandle "nelmio/solarium-bundle": "2.0.*@dev", "solarium/solarium": "3.0.*" 已经为我的doctrine php对象实现了ToSolrdDocument方法 public function toSolrDocument(\Solarium_Document_ReadWrite $doc

我对Solr非常陌生,我可能错过了一些简单的东西,但在完成演示后,我设置了Symfony2、Solarium和Nelmio\SolariumHandle

"nelmio/solarium-bundle": "2.0.*@dev",
"solarium/solarium": "3.0.*"
已经为我的doctrine php对象实现了ToSolrdDocument方法

public function toSolrDocument(\Solarium_Document_ReadWrite $doc)
{
    $doc->id          = $this->getId();
    $doc->description = $this->getTitle();
    $doc->path        = "path";

    return $doc;
}
我面临以下错误

可捕获的致命错误:传递给::toSolrDocument()的参数1必须是Solarium\u Document\u ReadWrite的实例,Solarium\QueryType\Update\Query\Document的实例,在Controller.php中调用

调用此toSolrDocument方法的控制器具有以下功能

public function indexItems(){

    $client = $this->get('solarium.client');

    // get an update query instance
    $update = $client->createUpdate();

    // create documents
    $documents = array();

    $em = $this->getDoctrine()->getManager();
    $repo = $em->getRepository('<Bundle>:<Object>');
    $items = $repo->findAll();


    foreach ($items as $item) {
        $documents[] = $item->toSolrDocument($update->createDocument());
    }

    // add the documents and a commit command to the update query
    $update->addDocuments($documents);
    $update->addCommit();

    // this executes the query and returns the result
    $result = $client->update($update);
}
例外是

FatalErrorException:错误:在中找不到类“Solarium\u Document\u ReadWrite”

我似乎在任何捆绑包中都找不到这个类,我想知道我的设置是否会导致这些问题。任何帮助都将不胜感激


另外一点需要注意的是,当我运行solr jar时,我看到查询请求来自我的symfony2页面,我无法完成这个索引操作,因此配置可能是正确的,我不理解捆绑包的用法。

您只需要为参数使用正确的类

use Solarium\QueryType\Select\Result\AbstractDocument;

...

public function toSolrDocument(AbstractDocument $doc)
{
您也无法键入提示:

public function toSolrDocument($doc)
{

谢谢我将Solarium\u Document\u ReadWrite更改为\Solarium\QueryType\Update\Query\Document。我遇到了另一个问题,您可能可以提供帮助。我想从同一solr安装运行多个站点。我在solr.xml中设置了多个核心,可以在solr admin中看到它们。但是,在我的symfony2项目中,我的配置没有加载集合核心。相反,我只在defaultCoreName属性的solr.xml文件中获取默认核心集。我是不是错过了另一个明显的机会?
public function toSolrDocument($doc)
{