V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
jahan

Elasticsearch 建立 mapping 的困惑,请高手指教。

  •  
  •   jahan · Feb 24, 2018 · 8153 views
    This topic created in 2990 days ago, the information mentioned may be changed or developed.

    我有一个数据库的建表语句。 create table。。。。 想根据这个语句在 es 里面建立相应的 mapping,这个有现成的工具可以进行转化吗? elasticsearch-sql 插件貌似不行?

    6 replies    2018-02-26 08:52:49 +08:00
    twm
        1
    twm  
       Feb 24, 2018 via iPhone
    发帖的时间不早建好了
    Morriaty
        3
    Morriaty  
       Feb 24, 2018
    logstash jdbc

    对于特殊的字段,需要自己写 template,比如 IP、timestamp
    Beebird
        4
    Beebird  
       Feb 24, 2018
    一般用 PUT /_template/xxxx 语句创建一个 template 就可以了,类似这样:

    "properties": {
    "@timestamp": {
    "type": "date",
    "format": "epoch_millis||basic_date_time"
    },
    "ipaddress": {
    "type": "ip",
    "ignore_malformed": true
    },
    "id": {
    "type": "string",
    "fields": {
    "raw": {
    "type": "string",
    "index": "not_analyzed"
    }
    }
    },
    "code": {
    "type": "integer",
    "ignore_malformed": true
    }
    }
    jahan
        5
    jahan  
    OP
       Feb 26, 2018
    @twm 比较懒,而且这个应该有个轮子吧。而且如果有了这么一个轮子,效率能提升很多。
    @ligyxy
    @Morriaty Logstash-input-jdbc 是用来从数据库导入的吧( This plugin was created as a way to ingest data in any database with a JDBC interface into Logstash. ),这个方法倒是特别适合已经有数据库的。不过我这里想着脱裤文件不入库直接进入 es。不知道还有没有。
    @Beebird 这个模板很好用,很想知道如果有一个建表语句,怎么对应出这样的模板,现在我是手敲。。。。非常 low。有没有一个工具,可以把 sql 语句的 create table 语句贴入或导入,然后根据一些配置,直接输出 mapping 呢?我分析的是脱裤文件,可能和大家分析的日志还不太一样。


    感谢大家指点。发现很多都是处理英文的,我需要处理的文本基本上都是中文,中文英混杂,数字串,金额,字母等。
    jahan
        6
    jahan  
    OP
       Feb 26, 2018
    @Morriaty 不过这个也是不错的办法。免去了建立 mapping 的麻烦?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2516 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 359ms · UTC 06:34 · PVG 14:34 · LAX 23:34 · JFK 02:34
    ♥ Do have faith in what you're doing.