我能够通过以下方式解决这个问题,首先在config.yml中创建了一个映射,如图所示
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
website:
client: default
index_name: docova
types:
documents:
mappings:
Doc_Title: ~
Description: ~
Attachments:
type: "object"
properties:
File_Name:
content:
type: attachment
persistence:
driver: orm
model: Docova\DocovaBundle\Entity\Documents
provider: ~
listener: ~
finder: ~
然后我需要对其中一个实体进行更改,以将附件作为二进制内容返回到弹性搜索,如下所示:
return file_get_contents($this->file_path . DIRECTORY_SEPARATOR . $this->getDocument()->getId() . DIRECTORY_SEPARATOR . md5($this->File_Name), 'r');
这为我解决了问题。