「必須匹配」我在日誌下面,我想用ElasticSearch查詢發現:在elasticsearchElasticsearch查詢日誌
2014-07-02 20:52:39 INFO home.helloworld: LOGGER/LOG:ID1234 has successfully been received, {"uuid"="abc123"}
2014-07-02 20:52:39 INFO home.helloworld: LOGGER/LOG:ID1234 has successfully been transferred, {"uuid"="abc123"}
2014-07-02 20:52:39 INFO home.byebyeworld: LOGGER/LOG:ID1234 has successfully been processed, {"uuid"="abc123"}
2014-07-02 20:52:39 INFO home.byebyeworld: LOGGER/LOG:ID1234 has exited, {"uuid"="abc123"}
2014-07-02 20:53:00 INFO home.helloworld: LOGGER/LOG:ID1234 has successfully been received, {"uuid"="def123"}
2014-07-02 20:53:00 INFO home.helloworld: LOGGER/LOG:ID1234 has successfully been transferred, {"uuid"="def123"}
2014-07-02 20:53:00 INFO home.byebyeworld: LOGGER/LOG:ID1234 has successfully been processed, {"uuid"="def123"}
2014-07-02 20:53:00 INFO home.byebyeworld: LOGGER/LOG:ID1234 has exited, {"uuid"="def123"}
由於上述各行表示爲單一的「消息」 ,我很難用POST休息調用來查詢它。我嘗試使用包含「必須匹配」只得到我的日誌的1號線,但它是不相符的,有時它會返回多個命中,而不是僅僅一重擊:
{
"query" : {
"constant_score" : {
"filter" : {
"bool" : {
"must" : [
{ "match_phrase_prefix" : {"message" : "home.helloworld:"}},
{ "match_phrase_prefix" : {"message" : "LOGGER/LOG:ID1234"}},
{ "match" : {"message" : "received, {\"uuid\"=\"abc123\"}"}}
]
}
}
}
}
}
難道我做錯了什麼上面elasticsearch查詢?我認爲「必須」等於AND,「匹配」更多的是CONTAINS,「match_phrase_prefix」是STARTSWITH?有人可以告訴我如何正確查詢充滿上述日誌與不同的uuid號碼的日誌,只返回單擊?最初我以爲我得到了與上述查詢,它首先返回只有1擊,但隨後返回2,然後更多..這對我來說是不一致的。先謝謝你!!