elasticsearch - 如何在 SOLR 中创建嵌套的 JSON 对象?
问题描述
我在 SOLR 数据库中转储数据。之前我使用的是 Elastic Search,它允许我存储嵌套的 JSON 对象。
在 SOLR 中插入时,有什么方法可以动态创建嵌套的 JSON 值?
我使用 JAVA 作为后端语言。我的代码是:
SolrInputDocument document = new SolrInputDocument();
document.addField("UUID", eventID);
document.addField("eventCategory", eventCategory);
.
.
.
.
document.addField("source", source);
I want something like this:
{
"UUID":"1",
"source":abcd,
"eventCategory": {
"event1":"a",
"event2":"b",
"event3":"c"
}
}
解决方案
Solr 是平面模式文档的集合。您可以向 solr 添加动态字段,但它不支持嵌套的 JSON 对象。
但是您可以使用以下资源中指定的嵌套文档。
https://lucene.apache.org/solr/guide/6_6/uploading-data-with-index-handlers.html
但是查询子文档并不像 ElasticSearch 或 MongoDB 那样简单。
推荐阅读
- c# - Azure DevOps NuGet Pack 忽略 csproj 包详细信息
- python - 询问用户他们收集了多少天的宝石
- opengl - 如何在 Python OpenGL 中移动箭头的原点?
- opengl - 活塞中的纹理转换
- css - Wordpress 和 Elementor 不显示所有样式(仅在定制器预览中显示)
- css - Blazor + Bootstrap + SCSS 中的 CSS 隔离:可以吗?(::深度选择器)
- python - 如何将一维 numpy 数组拆分为块,每个块的长度取决于条件
- sql - 结构和数组 - 错误:标量子查询产生了多个元素
- c# - 如何在 Windows 10 中打开“输入网络凭据”
- javascript - moment 和 moment.utc 有什么区别