简体   繁体   English

从一对多关系的关系数据库表中索引数据的最佳方法是

[英]Which is the best way to index the data from relational database table of One to many relationship

Can you please let me know which is the best way to index the records in elastic search for my scenario. 您能告诉我哪种方法是对我的方案进行弹性搜索时对记录建立索引的最佳方法。

My Scenario is : 我的场景是:

1) Need to index around 40 million records from oracle table which has entries having one to many relationship records. 1)需要从oracle表中索引约4000万条记录,该表的条目具有一对多的关系记录。 And the uniqueness of the records is based on the composite key with 4 columns 记录的唯一性基于具有4列的组合键

2) After indexing , Search should support "full text search" on all the fields 2)建立索引后,搜索应在所有字段上支持“全文本搜索”

3) Filters and sorting on selected fields needs to be supported. 3)需要支持对选定字段的过滤和排序。

After going through the official documentation i found couple of options , but want to know which approach would be most useful among below 在查阅了官方文档之后,我发现了几种选择,但是想知道下面哪种方法最有用

1) For each record in table create a entry in the elastic index 1)为表中的每个记录在弹性索引中创建一个条目

2) Create a nested json object based on the composite key and then add this elastic index 2)根据复合键创建一个嵌套的json对象,然后添加此弹性索引

3)Parent child Relationship mechanism and application side joins are not suitable for my scenario 3)父子关系机制和应用程序侧联接不适合我的情况

Thanks 谢谢

Girish TS 吉里什TS

Your question is not particularly clear, here's how I understand it: you have 40M child records in one table, each with a reference to a parent record. 您的问题不是特别清楚,这是我的理解方式:您在一个表中有4000万个子记录,每个子记录都引用了一个父记录。 You want to index your records so as to be able to search for a parent record whose children match certain criteria. 您希望索引您的记录,以便能够搜索其子项符合特定条件的父记录。

There are two solutions here: 这里有两种解决方案:

  • Indexing one document per parent, with all children indexed as nested documents within the parent 每个父级为一个文档编制索引,所有子级都作为父级中的嵌套文档进行索引

  • Indexing each child record as a separate document, with a parent-child relationship in ElasticSearch 将每个子记录索引为一个单独的文档,并在ElasticSearch中具有父子关系

The first solution will have better performance, but it means that every time a child is updated, the full parent document must be reindexed with all its children. 第一个解决方案将具有更好的性能,但是这意味着每次更新子级时,都必须使用其所有子级对整个父级文档进行索引。

In any case you're saying that a parent-child scheme is not suitable for your case, so you're left with only the first solution. 无论如何,您要说的是父子方案不适合您的情况,因此您只剩下第一个解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果是,那么在弹性搜索中将关系数据库表存储为不同的索引是否好,然后如何在索引中传递关系 - Is it good to store relational database table as different index in elastic-search if yes then how to pass relationship in index 将数据从Oracle /关系表索引到弹性搜索的更好方法是什么? - what is the better way to index data from Oracle/relational tables into elastic search? elasticsearch嵌套索引关系数据库 - elasticsearch nest index relational database 在ElasticSearch上索引聚合数据的最佳方法是什么 - What is the best way to index aggregate data on ElasticSearch 在Elasticsearch上索引数据的最佳方法是什么? - What is the best way to index data on elasticsearch? 如何将数据从 elasticsearch 提取到关系数据库(如 Oracle)? - How can I take data from elasticsearch to relational database such as Oracle? Logstash并从关系表中查找其他数据? - Logstash and looking up additional data from a relational table? 在关系数据库之前将记录放入Elasticsearch索引中 - Putting records into the Elasticsearch index before the relational database 在现有的sqlite关系数据库中创建Index Elasticsearch - Create Index Elasticsearch in existing sqlite relational database 弹性搜索索引和关系数据库中的索引有什么区别? - What is the difference between an elastic search index and an index in a relational database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM