【发布时间】:2021-09-04 16:50:43
【问题描述】:
我是一名 Elasticsearch 新手,遇到了有关将 ES 与 MongoDB 结合使用以获得文本索引/搜索功能的建议。
我想要实现的是分析我的 Mongo 集合中的文本,然后根据文本上下文在相似内容之间建立关联。
例如:
Collection A =>
{
id:1,
text: 'The sly Fox dug a tunnel under the Fence to snatch a Hen',
}
{
id:2,
text: 'Jack the farmer built a fence to protect his Hens',
associated: [id4,id1,...]
}
{
id:3,
text: 'Jack listened to his radio and called it a night',
}
{
id:4,
text: 'The farmer Jack plowed the field'
}
然后系统应按以下顺序关联这些文档:
- id2 id4 # "The farmer Jack" - n-gram
- id2 id1 # 围栏和母鸡
- ...等等。
解决这个问题的一种低效方法是,一旦我在 Elasticsearch 中创建了 Collection A 的索引,我就可以编写一个批处理过程来循环遍历每个 n-gram 并在 ES 中搜索它,然后将结果推送回集合 A(参见关联)。
我想一定有一种更简单的方法可以做到这一点,而且我可能会遗漏一些东西。有没有 ?如果是这样,它是什么或者我在哪里可以找到关于它的好的参考资料?
【问题讨论】:
标签: node.js mongodb elasticsearch