python - 将 REST API 的 JSON 响应作为输入数据传递到 APACHE SOLR 中

标签 python json apache api solr

我有一个使用 Flask 构建的 REST API。它有 GET 和 POST 方法。 API 返回 JSON 响应。我希望 SOLR 使用 REST API 的 URL 根据查询对此响应执行搜索并返回相关搜索结果。

我怎样才能实现这个目标? SOLR 是否只接受 JSON 文件 作为输入,在这种情况下,我需要将端点的响应写入 JSON 文件,将其放置在示例文件夹中并将其传递到 SOLR 中?

最佳答案

I want SOLR to use the REST API's URL to perform search on the data(JSON response) based on the query and return relevant search results

您必须调用 REST API,获取 JSON 响应并将其添加到 Solr 索引。然后您可以使用 Solr 搜索该数据。

Could you please let me know how to achieve this? Is it possible?

请查看此文档。它将帮助您索引 JSON 文档。 https://lucene.apache.org/solr/guide/7_1/uploading-data-with-index-handlers.html#solr-style-json

Or does SOLR only take JSON file as input placed in the example folder, in which case, I would need to write the response received from my RESTAPI to a json file, place it in the example folder and pass it into SOLR

这是部分正确的理解,但是您不必将其放在示例文件夹中。您需要发布该 JSON(或按照 Solr 要求的格式格式化 JSON),如上面提供的引用所示。

希望这有帮助。

关于python - 将 REST API 的 JSON 响应作为输入数据传递到 APACHE SOLR 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54330678/

相关文章:

python - Falcon 框架响应对象 : resp. 媒体与 resp.body

java - 无法使用动态数据在 RecyclerView 中显示项目

linux - CentOS 7.2的apache无法卸载

apache - ssl 证书适用于服务器还是主机名?

python - 理解 Python 3 中的非本地

python - 将用户名和密码存储到字典中?

javascript - PHP 的 AJAX 错误处理

python - 通过 redis-py 将 .json 文件导入到 redis 数据库

python - CherryPy:创建在 apache2 后面运行的 Web 服务 (mod_wsgi)

python - 让 virtualenv 从你的全局站点包中继承特定的包