Giter Site home page Giter Site logo

hive2elastic's Introduction

hive2elastic

hive2elastic synchronises hive's hive_posts_cache table to a elasticsearch index and keeps it updated.

Before start

Some additional database objects have to be created on hive's database.

Follow steps below:

1- Stop hive. Make sure all hive processes stopped.

2- Create database objects on hive's database.

CREATE TABLE __h2e_posts
(
    post_id INTEGER PRIMARY KEY
);
INSERT INTO __h2e_posts (post_id) SELECT post_id FROM hive_posts_cache;
CREATE OR REPLACE FUNCTION __fn_h2e_posts()
  RETURNS TRIGGER AS
$func$
BEGIN   
    IF NOT EXISTS (SELECT post_id FROM __h2e_posts WHERE post_id = NEW.post_id) THEN
    	INSERT INTO __h2e_posts (post_id) VALUES (NEW.post_id);
	END IF;
	RETURN NEW;
END
$func$ LANGUAGE plpgsql;
CREATE TRIGGER __trg_h2e_posts
AFTER INSERT OR UPDATE ON hive_posts_cache
FOR EACH ROW EXECUTE PROCEDURE __fn_h2e_posts();

3- Start hive

Make sure database credentials that you use has delete permission on __h2e_posts table

Elasticsearch

You can find detailed installation instructions here

Installation

$ git clone https://github.com/esteemapp/hive2elastic
$ cd hive2elastic
$ pip3 install -e .

Configuration

You can configure hive2elastic by these arguments/environment variables:

Argument Environment Variable Description Default
--db-url DB_URL Connection string for hive database --
--es-url ES_URL Elasticsearch server address --
--es-index ES_INDEX Index name on elasticsearch hive_posts
--es-type ES_TYPE Type name on elasticsearch index hive_posts
--bulk-size BULK_SIZE Number of documents to index in a single loop 500
--max-workers MAX_WORKERS Max workers for document preparation process 2

Example configuration and running

$ export DB_URL=postgresql://username:passwd@localhost:5432/hive 
$ export ES_URL=http://localhost:9200/
$ export BULK_SIZE=2000                 
$ export MAX_WORKERS=4

$ hive2elastic_post

hive2elastic's People

Contributors

talhasch avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.