Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Nodejs和postgresql中的Elasticsearch jdbc导入程序_Node.js_Postgresql_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Jdbc - Fatal编程技术网 elasticsearch,jdbc,Node.js,Postgresql,elasticsearch,Jdbc" /> elasticsearch,jdbc,Node.js,Postgresql,elasticsearch,Jdbc" />

Node.js Nodejs和postgresql中的Elasticsearch jdbc导入程序

Node.js Nodejs和postgresql中的Elasticsearch jdbc导入程序,node.js,postgresql,elasticsearch,jdbc,Node.js,Postgresql,elasticsearch,Jdbc,我想在我的项目中使用Elasticsearch。我正在使用Nodejs和postgresql 我想将postgresql与我正在使用的elasticsearch连接起来。我按照他们文档中写的步骤连接到postgresql,并通过命令行成功地实现了这一点 我想通过nodejs在我的项目中使用jdbc导入器 运行jdbc导入程序的commondline代码: bin=/Users/mac/Documents/elasticsearch-jdbc-2.3.4.1/bin lib=/Users/mac/

我想在我的项目中使用Elasticsearch。我正在使用Nodejs和postgresql

我想将postgresql与我正在使用的elasticsearch连接起来。我按照他们文档中写的步骤连接到postgresql,并通过命令行成功地实现了这一点

我想通过nodejs在我的项目中使用jdbc导入器

运行jdbc导入程序的commondline代码:

bin=/Users/mac/Documents/elasticsearch-jdbc-2.3.4.1/bin
lib=/Users/mac/Documents/elasticsearch-jdbc-2.3.4.1/lib
echo '{
     "type" : "jdbc",
     "jdbc" : {
         "url" : 
        "jdbc:postgresql://localhost:5432/development",
        "sql" : "select * from \"Products\"",
         "index" : "product",
         "type" : "product",
    "elasticsearch" : {
    "cluster" : "elasticsearch",
    "host" : "localhost",
    "port" : 9300
}
     }
 }' | java \
        -cp "${lib}/*" \
        org.xbib.tools.Runner \
        org.xbib.tools.JDBCImporter
上面的命令已经在elasticsearch中创建了索引产品,它还包含来自postgresql产品表的数据

现在,我想通过nodejs使用jdbc导入器,如果其他人知道在elasticsearch中管理我的postgresql数据的其他有效方法,也欢迎他们提供Answare。

您可以使用Logstash:

有了它,你可以将数据从Postgres传输到ElasticSearch。这是我的配置文件:

input { 
  jdbc {
    # Postgres jdbc connection string to our database, mydb
    jdbc_connection_string => "jdbc:postgresql://localhost:5432/MyDB"
    # The user we wish to execute our statement as
    jdbc_user => "postgres"
    jdbc_password => ""
    # The path to our downloaded jdbc driver
    jdbc_driver_library => "postgresql-42.1.1.jar"
    # The name of the driver class for Postgresql
    jdbc_driver_class => "org.postgresql.Driver"
    # our query
    statement => "SELECT * from contacts"
  }
}
output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "contacts"
    document_type => "contact"
    document_id => "%{uid}"
  }
}