如何使用 Elastica 不存储附件内容
How to not store attachment content using Elastica
当我像这样配置映射时:
$mapping = new Mapping(…);
$mapping->setProperties([
…
'my_attachments' => [ 'type' => 'attachment', 'include_in_all' => true ]
]);
它正在存储文件的 base64 编码内容并将索引增加到荒谬的大小。我如何才能确保附件确实被编入索引和可搜索,但不将其编码内容存储在索引中?
我们需要设置_source
排除my_attachments
值:
$mapping = new Mapping(…);
$mapping->setProperties([
…
'my_attachments' => [ 'type' => 'attachment', 'include_in_all' => true ]
]);
$mapping->setSource([ 'excludes' => 'my_attachments' ]);
实施此操作并重建我们的测试索引后,大小从 1.9GB 下降到 89MB。
当我像这样配置映射时:
$mapping = new Mapping(…);
$mapping->setProperties([
…
'my_attachments' => [ 'type' => 'attachment', 'include_in_all' => true ]
]);
它正在存储文件的 base64 编码内容并将索引增加到荒谬的大小。我如何才能确保附件确实被编入索引和可搜索,但不将其编码内容存储在索引中?
我们需要设置_source
排除my_attachments
值:
$mapping = new Mapping(…);
$mapping->setProperties([
…
'my_attachments' => [ 'type' => 'attachment', 'include_in_all' => true ]
]);
$mapping->setSource([ 'excludes' => 'my_attachments' ]);
实施此操作并重建我们的测试索引后,大小从 1.9GB 下降到 89MB。