zombodb 是一個很不錯的pg 擴展,能夠方便的把es 與pg 集成起來,使用方便 ,目前儘管有一些docker 鏡像
可是版本都比較老,因此基於centos7 作了一個新的docker 鏡像,同時基於view 的方式集成hasura graphql-engine html
FROM centos/postgresql-10-centos7 LABEL mail="1141591465@qq.com" LABEL author="dalong" COPY zombodb_centos7_pg10-10-1.0.3_1.x86_64.rpm /app/zombodb_centos7_pg10-10-1.0.3_1.x86_64.rpm USER root RUN rpm -Uvh /app/zombodb_centos7_pg10-10-1.0.3_1.x86_64.rpm RUN cp -rf /usr/pgsql-10/share/extension/* /opt/rh/rh-postgresql10/root/usr/share/pgsql/extension RUN cp /usr/pgsql-10/lib/zombodb.so /opt/rh/rh-postgresql10/root/lib64/pgsql/ USER postgres
說明
由於rpm 包安裝的問題,上邊的擴展須要從新copy 目錄git
version: '3' services: elasticsearch: image: elasticsearch:6.6.0 ports: - "9200:9200" environment: - http.host=0.0.0.0 - transport.host=0.0.0.0 - network.host=0.0.0.0 - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 postgresql_db: build: ./ image: dalongrong/zombodb-postgresql-10-centos7 ports: - "5432:5432" environment: - "POSTGRESQL_ADMIN_PASSWORD=dalong" graphql-engine: image: hasura/graphql-engine:v1.0.0-alpha41 ports: - "8080:8080" environment: - "POSTGRES_PASSWORD:dalong" command: > /bin/sh -c " graphql-engine --database-url postgres://postgres:dalong@postgresql_db:5432/postgres serve --enable-console; "
docker-compose build
docker-compose up -d
CREATE EXTENSION zombodb;
CREATE TABLE products ( id SERIAL8 NOT NULL PRIMARY KEY, name text NOT NULL, keywords varchar(64)[], short_summary text, long_description zdb.fulltext, price bigint, inventory_count integer, discontinued boolean default false, availability_date date );
注意使用的es 的地址,使用容器服務的github
CREATE INDEX idxproducts ON products USING zombodb ((products.*)) WITH (url='http://elasticsearch:9200/');
COPY products FROM PROGRAM 'curl https://raw.githubusercontent.com/zombodb/zombodb/master/TUTORIAL-data.dmp';
SELECT * FROM products WHERE products ==> 'sports box';
效果sql
2 Baseball {baseball,sports,round} It's a baseball Throw it at a person with a big wooden stick and hope they don't hit it 1249 2 FALSE 2015-08-21 4 Box {wooden,box,"negative space",square} Just an empty box made of wood A wooden container that will eventually rot away. Put stuff it in (but not a cat). 17000 0 TRUE 2015-07-01
具體操做就是鼠標點擊,對於hasura graphql-engine 的集成,經過view 方式,也能夠基於dsl 查詢的方式(實際上仍是view)docker
- 添加view 視圖
create view zombodb_hg as SELECT * FROM products WHERE products ==> 'sports box';
https://www.cnblogs.com/rongfengliang/p/10635311.html
https://github.com/rongfengliang/zombodb-hasura-graphql
https://github.com/rongfengliang/zombodb-docker-imagecentos