SearchReplica
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Basic Setup

We’ll start simple, with one table about blog posts that we need to be indexed as is.

  1. (optional) for sandbox, do cleanup:

    DROP PUBLICATION IF EXISTS "search";
    
    curl -XDELETE 'http://127.0.0.1:9200/postgres'
    
  2. create table(s):

    CREATE TABLE public.posts
    (
        id bigserial NOT NULL,
        title text NOT NULL DEFAULT '',
        content text NOT NULL DEFAULT '',
        PRIMARY KEY (id)
    );
    
  3. configure table: (wouldn’t be required in future)

    COMMENT ON TABLE public.posts IS 'index:",all"'; -- index all fields by default
    
  4. expose the table in a publication

    CREATE PUBLICATION "search" FOR TABLE public.posts;
    
  5. add some data

    INSERT INTO public.posts( title, content) VALUES ( 'Post 1', 'Super content here');
    INSERT INTO public.posts( title, content) VALUES ( 'Post 2', 'Boring news article');
    
  6. restart search-replica

  7. add more content

    INSERT INTO public.posts( title, content) VALUES ( 'This is streaming replication', 'how long did it take to arrive in Elastic');
    INSERT INTO public.posts( title, content) VALUES ( 'Im volcano', 'My name is Eyjafjallajökull');
    UPDATE public.posts SET content='Updated interesting article' WHERE title='Post 2';