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

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

  •  
  •   hagezhou · Oct 25, 2017 · 7111 views
    This topic created in 3112 days ago, the information mentioned may be changed or developed.

    比如,我一般 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 replies    2017-10-25 16:00:52 +08:00
    hagezhou
        2
    hagezhou  
    OP
       Oct 25, 2017
    @YuexLi 嗯,这个后来有试过,但是貌似只支持字符串?如果 mapping 里面设定的字段类型为 long,貌似不行?
    ctsed
        3
    ctsed  
       Oct 25, 2017 via Android
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2590 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 14:44 · PVG 22:44 · LAX 07:44 · JFK 10:44
    ♥ Do have faith in what you're doing.