简体   繁体   English

将数据库内容索引到弹性搜索

[英]indexing db content to elastic search

Hello all I am working on a Django project with backend database as a PostgreSQL server. 您好,我正在将后端数据库作为PostgreSQL服务器的Django项目进行工作。 and I have chosen elastic search as a search engine for my project. 并且我选择elastic search作为我的项目的搜索引擎。

I have used elastic search-dsl-py to create a mapping between Django models and elastic search doc type. 我使用了elastic search-dsl-py在Django模型和elastic search文档类型之间创建映射。 and use Django signals to capture update and delete events. 并使用Django signals捕获updatedelete事件。

By the way, I haven't mapped all the fields from Django model to elastic search. 顺便说一下,我还没有将Django模型中的所有字段都映射到弹性搜索。

When a user search to he/she get's a list of an item to homepage from elastic search server. 当用户搜索他/她时,会从弹性搜索服务器获得要在主页上显示的项目列表。 When user clicks to the item list. 用户单击到项目列表时。 Where should I query the detail data of an item, in the elastic_search server or in the Postgres server elastic_search serverPostgres server ,应在哪里查询项目的明细数据?

If I put all the details of every object in an elastic server, It will going to be a pain for me as, there is a nested relation in Django models. 如果我将每个对象的所有详细信息都放在弹性服务器中,这将使我很痛苦,因为Django模型中存在嵌套关系。

If I don't put all the details in elastic search server, I need to query to the database, to get the detail of an item which is going to be slow as compared to an elastic search query. 如果我没有将所有详细信息放在弹性搜索服务器中,则需要查询数据库,以获取与弹性搜索查询相比要慢的项目的详细信息。

Which approach should I go? 我应该采取哪种方法?

Index all the properties along with the nested relation in elastic search server and do all the querying operation to elastic search. 在弹性搜索服务器中索引所有属性以及嵌套关系,并对弹性搜索执行所有查询操作。

OR 要么

Index only the necessary field in elastic search server, and for the detail view, do q query to the database with the required field id. 仅对弹性搜索服务器中的必要字段建立索引,对于详细视图,请使用必需的字段ID对数据库进行q查询。

Does anyone have this kind of experience before? 有人有过这种经历吗?

This decision really depends on what you are trying to address with elastic search. 这个决定实际上取决于您要通过弹性搜索解决的问题。 Recently I worked on a project that used elastic search. 最近,我从事一个使用弹性搜索的项目。 The reason was to speed up searching and to provide better search result. 原因是加快搜索速度并提供更好的搜索结果。 However the detail of selected product is queried from the database (mssql). 但是,可以从数据库(mssql)查询所选产品的详细信息。 The decision to map all or few fields depends on what you wanted out of elastic search.If its for better search result (result + speed) then I suggest you only map those fields that help user for searching. 决定是全部还是少数几个字段的映射取决于您想要进行弹性搜索的目的。如果要获得更好的搜索结果(结果+速度),那么我建议您仅映射那些有助于用户搜索的字段。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM