【问题标题】:Elasticsearch and MongoDB n-gram indexing for each mongo document in collection集合中每个 mongo 文档的 Elasticsearch 和 MongoDB n-gram 索引
【发布时间】: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


    【解决方案1】:

    在 ElasticSearch 中没有简单的方法可以做到这一点。最简单的方法是在运行时进行第二次搜索以检索相关内容。

    因为它是动态内容,如果你索引它,它可能不会在某些时候更新,除非索引大小是固定的。

    如果你真的想索引结果,我会说你的批次是一个解决方案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-30
      • 2021-10-27
      相关资源
      最近更新 更多