通过 KIBANA 摄取 PDF

PDF ingesting through KIBANA

我是 Elasticsearch 的新手,有一些要求我需要使用 Kibana 摄取和索引 pdf。我发现我们必须为上述目的创建一个管道,但不知道要使用哪个处理器以及我应该如何配置它们。我发现我的 Elasticsearch 节点安装了 ingest-attachment 插件。我使用的版本是Elasticsearch 7.14,所以任何帮助都非常感谢谢谢。

这可能对您有用,摄取附件处理器插件对 pdf 使用 base64 来提取和摄取数据。您将需要获取 base64 并将其摄取到管道中。例如:

encoded_data = base64.b64encode(data).decode('utf-8') # data is the file that you are parsing

body = {    
        'query': { 
            'bool': {
                "filter": [
                    {"ids": { 'values': [contentDocumentId]}},
                    {"term": {"contentVersionId": contentVersionId}}
                ]
            }
        },
        'script': {
            'source': 'ctx._source["file_data"] = params._file_data',
            'params': {'_file_data': encoded_data}
        }
    }
    response = client.update_by_query(conflicts='proceed', index=_index, pipeline='attachment', body=json.dumps(body))

我正在使用查询更新我的用例你可以检查你是想使用更新还是查询更新