简体   繁体   中英

indexing db content to elastic search

Hello all I am working on a Django project with backend database as a PostgreSQL server. and I have chosen elastic search as a search engine for my project.

I have used elastic search-dsl-py to create a mapping between Django models and elastic search doc type. and use Django signals to capture update and delete events.

By the way, I haven't mapped all the fields from Django model to elastic search.

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

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.

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.

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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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