2016-06-21 325 views

回答

0

你可以,如果你使用的是elasticsearch通過logstash做到這一點。

運行logstash進程與配置類似

input { 
    elasticsearch { 
    hosts => "your_host" 
    index => "your_index" 
    query => "{ "query": { "match_all": {} } }" 
    } 
} 
filter { 
    grok { 
    match => { "your_string_field" => "%{NUMBER:num1} %{GREEDYDATA:middle_stuff} %{NUMBER:num2} %{GREEDYDATA:other_stuff}" } 
    } 
    mutate { 
    remove_field => ["middle_stuff", "other_stuff"] 
    } 
} 
output{ 
    elasticsearch { 
    host => "yourhost" 
    index => "your index" 
    document_id => %{id} 
    } 
} 

這將基本上覆蓋每個文檔中索引有兩個字段,NUM1和NUM2對應於你正在尋找的數字。這只是一個快速和骯髒的方法,會佔用更多的內存,但可以讓您一次完成所有分解,而不是在可視化時間。

我相信有一種方法可以通過腳本執行此操作,請查看groovy正則表達式匹配返回特定組的位置。

也不保證我的配置表示是正確的,因爲我目前沒有時間測試它。

祝您有美好的一天!