首页 > 解决方案 > 批量请求中的错误:索引:...导致解析失败

问题描述

我在使用 FOSElastica 捆绑包配置时遇到问题。我正在尝试使用 Symfony 序列化程序使用 FOSElastica 填充弹性搜索,它适用于不需要具有属性组的简单对象,但是当我尝试仅序列化一组属性时,我得到的是以下错误:

In Bulk.php line 411:

  Error in one or more bulk request actions:        

  index: /journal/journal/2 caused failed to parse  
  index: /journal/journal/3 caused failed to parse  
  index: /journal/journal/4 caused failed to parse

我的配置文件:

fos_elastica:
    serializer: ~
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        journal:
            types:
                journal:
                    serializer:
                        groups: [elastica]
                    persistence:
                        driver: orm
                        model: TAMAS\AstroBundle\Entity\Journal

我的“期刊”实体:

use Symfony\Component\Serializer\Annotation\Groups;

/**
 * Journal
 *
 * @ORM\Table(name="journal")
 * @ORM\Entity(repositoryClass="TAMAS\AstroBundle\Repository\JournalRepository")
 * @UniqueEntity(fields="journalTitle", message="This title is already recorded in the database.")

 */
class Journal {

    /**
     * @Groups({"elastica"})
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="journal_title", type="string", length=500)
     * @Assert\NotBlank()
     */
    private $journalTitle;

    /**
     * @Groups({"elastica"})
     * Get id
     *
     * @return int
     */
    public function getId() {
        return $this->id;
    }

    /**
     * @Groups({"elastica"})
     * Set id
     *
     * @param int $id
     *
     * @return Journal
     */
    public function setId($id) {
        $this->id = $id;
        return $this;
    }

    /**
     * Set journalTitle
     *
     * @param string $journalTitle
     *
     * @return Journal
     */
    public function setJournalTitle($journalTitle) {
        $this->journalTitle = $journalTitle;

        return $this;
    }

    /**
     * Get journalTitle
     *
     * @return string
     */
    public function getJournalTitle() {
        return $this->journalTitle;
    }
}

如果我不输入配置文件:

                    serializer:
                        groups: [elastica]

对于这样的实体,没关系,映射完成,elasticsearch 成功填充索引。但是对于具有循环引用的实体,例如,我需要序列化程序和组。你知道问题可能是什么吗?

作为参考,我正在使用 Eclipse/Sublime Text 编码/编辑文件,并通过命令和 curl 请求进行测试。

编辑:我已经安装了 JMS/serializer-bundle,它工作正常。我认为 FOSElastica 包和 Symfony 序列化程序之间存在真正的问题。感觉像是一种解决方法,所以如果有人对两者之间的问题有见解,它仍然会很有趣

标签: phpelasticsearchelasticafoselasticabundle

解决方案


推荐阅读