1

我使用 logstash 从数据库(在本例中为 Postgres)中索引数据并将其放入 Elasticsearch 索引中。这是我的配置:

input {

    jdbc {
        jdbc_driver_library => "/path/to/driver"
        jdbc_driver_class => "org.postgresql.Driver"
        jdbc_connection_string => "jdbc:postgresql://POSTGRE_HOST:5432/db"
        jdbc_user => "postgres"
        jdbc_password => "top-secret"
        statement => "SELECT id, title, description, username FROM products"
        add_field => [ "type", "product" ]
    }
}

output {
    if [type] == "product" {
        elasticsearch {
            action => "index"
            hosts => "localhost:9200"
            index => "products"
            document_id => "%{id}"
            document_type => "%{type}"
            workers => 1
        }
    }
}

问题:如何为我的 SQL 查询定义映射,以便例如标题 + 描述被索引为文本,但用户被索引为关键字数据类型?

4

0 回答 0