R
R
rraderio2017-01-04 17:18:09
PostgreSQL
rraderio, 2017-01-04 17:18:09

How to do searches with Elasticsearch/PostgreSQL?

I have a base with products

CREATE TABLE products (
id BIGSERIAL NOT NULL PRIMARY KEY,
title VARCHAR(100) NOT NULL,
description TEXT NULL,
price BIGINT NOT NULL
);

How to make it so that when adding / changing in PostgreSQL, the data is automatically updated in Elasticsearch?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2017-01-04
@sergey-gornostaev

The easiest way is to send data from the code to Elasticsearch and PostgreSQL in parallel. And you can pile up the system from a trigger, a notification mechanism and a handler for these notifications, which will send data to Elasticsearch. But it won't be easy.

A
al_gon, 2017-01-04
@al_gon

reindex only changed ones!

  1. in add columns PostgreSQLlast_update products(timestamp) and indexed (1/0)
  2. save in the Elasticsearchproduct ID, be sure to understand it and the selection will take place.
  3. store last indexing time, global value for the entire index.
  4. run a daemon program that reindexes changed products.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question