logstash ELK和Spring环境中的字符串数组

mbjcgjjk  于 9个月前  发布在  Logstash
关注(0)|答案(1)|浏览(161)

在ELK环境中,我有一个管道,语句如下:

SELECT id,
       types::text,
FROM example_table
WHERE last_modified_date > :sql_last_value
ORDER BY id DESC

字符串
模板是这样的:

{
  "index_patterns": [
    "example_records*"
  ],
  "version": 1,
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "@version": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "id": {
        "type": "long"
      },
      "types": {
        "type": "text"
      }
    }
  }
}

  • types* 列的类型为jsonb(PostgreSQL),包含值:["TYPE_1", "TYPE_2"]

我想通过Spring应用程序从example_table读取记录,其中我有一个类

@Document(indexName = "example_records", createIndex = false)
@Data
public class ElasticExampleRecord {
    @Id
    @Field(name = "id")
    private final Long id;

    @Field(name = "types")
    private final List<ExampleType> types;
}


但我得到的数据是字符串列表,其中0索引是像["TYPE_1", "TYPE_2"]这样的数组:

result.types.size() == 1
result.types.get(0) == "["TYPE_1", "TYPE_2"]".


我试图删除SQL语句中的::text转换,但我得到了错误

MissingConverterException: Missing Converter handling for full class name=org.postgresql.util.PGobject, simple name=PGobject".


所以我把这个铸件退回去了
我试图删除管道中的类型,但结果是一样的。
我试图在管道中设置nested类型,但记录没有显示在索引中。
我该怎么办?

svmlkihl

svmlkihl1#

您应该将字段从text迁移到keyword
在这种情况下,每个新单词都将是数组的一部分。
举例来说:


的数据
在文档中,

{                   
  "warnings": [ "CARDHOLDER_INVALID", "WEAK_PASSWORD"]
}

字符串
要真正将字段迁移到新类型,您应该使用reindex
我将添加指南以防万一https://opster.com/guides/elasticsearch/data-architecture/elasticsearch-change-field-type/

相关问题