V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hagezhou
V2EX  ›  Elasticsearch

ES 中 match 里面怎么加正则匹配

  •  
  •   hagezhou · 2017-10-25 11:47:04 +08:00 · 4324 次点击
    这是一个创建于 2346 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如,我一般 match 可以这么写

    ··· { "query":{ "bool":{ "must":[ { "range":{ "timestamp":{ "gt":"now-1h" } } }, { "match":{ "info.sourceIp":{ "query":"1.191.187.3", "type":"phrase" } } }, { "match":{ "hostname":{ "query":"file2", "type":"phrase" } } } ] } } } ···

    如果 match 中加正则怎么写呢,比如要查询 hostname 中,1 开头的

    3 条回复    2017-10-25 16:00:52 +08:00
    hagezhou
        2
    hagezhou  
    OP
       2017-10-25 15:54:45 +08:00
    @YuexLi 嗯,这个后来有试过,但是貌似只支持字符串?如果 mapping 里面设定的字段类型为 long,貌似不行?
    ctsed
        3
    ctsed  
       2017-10-25 16:00:52 +08:00 via Android
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1137 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 18:38 · PVG 02:38 · LAX 11:38 · JFK 14:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.