php - 批量请求中的错误:索引:...导致解析失败
问题描述
我在使用 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 序列化程序之间存在真正的问题。感觉像是一种解决方法,所以如果有人对两者之间的问题有见解,它仍然会很有趣
解决方案
推荐阅读
- python-3.x - 具有多个树视图小部件的 Python 树视图标题背景颜色
- node.js - 使用 Electron/Nodejs 将数据从服务器传递到 html
- visual-studio-2019 - Visual Studio 2019 - 无法将网站发布到本地文件夹
- c++ - 从第二个字符串组成一个字符串,字符顺序
- html - CSS在悬停时将背景颜色应用于div,但仅当链接悬停时
- node.js - 如何使用 Nodejs 将超链接添加到现有 PDF?
- javascript - HTML 输入到数字和添加
- powershell - 从 Hashicorp Vault 将机密复制到 Azure Key Vault
- http - 更改 web html 内容/在 http 请求上运行 bash 脚本
- c# - 如何在 VS 2019 中将 XNA 与 Windows 窗体匹配?