2017-07-14 52 views
0

我想按功能路徑聚合訪問。ElasticSearch - 如何聚合訪問日誌忽略GET參數?

{ 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "wildcard": { 
      "path.keyword": "/hex/*" 
      } 
     } 
     ] 
    } 
    }, 
    "from": 0, 
    "size": 0, 
    "aggs": { 
    "path": { 
     "terms": { 
     "field": "path.keyword" 
     } 
    } 
    } 
} 

,我得到的結果類似這樣..

{ 
    "key": "/hex/user/admin_user/auth", 
    "doc_count": 38 
}, 
{ 
    "key": "/hex/report/chart/fastreport_lobby_all?start_date=2017-06-29&end_date=2017-07-05&category=date_range&value[]=payoff", 
    "doc_count": 35 
}, 
{ 
    "key": "/hex/report/chart/fastreport_lobby_all?start_date=2017-06-29&end_date=2017-07-05&category=lobby&value[]=payoff", 
    "doc_count": 35 
}, 
{ 
    "key": "/hex/report/chart/online_membership?start_date=2017-06-29&end_date=2017-07-05&category=datetime_range&value[]=user_total", 
    "doc_count": 34 
} 

有兩個/六/報告/圖表/ fastreport_lobby_all?BALABALA ...結果。

這不是關於此功能的真正計數。

我有任何方法可以將這些統計爲一個嗎?

{ 
    "key": "/hex/report/chart/fastreport_lobby_all", 
    "doc_count": 70 
} 

回答

1

我不認爲這是可能的,而不自定義分析儀像

PUT your_index 
{ 
    "settings": { 
     "analysis": { 
     "analyzer": { 
      "query_analyzer": { 
       "type": "custom", 
       "tokenizer": "split_query", 
       "filter": ["top1" 
       ] 
      } 
     }, 
     "filter":{ 
      "top1":{ 
        "type": "limit", 
        "max_token_count": 1 
        } 
     }, 
     "tokenizer":{ 
      "split_query":{ 
        "type": "pattern", 
        "pattern": "\\?" 
       } 
     } 
     } 
    }, 
    "mappings": { 
     "your_log_type": { 
     "properties": { 
      "path": { 
       "type": "text", 
       "fields": { 
        "keyword": { 
         "type":"keyword" 
        }, 
        "no_query": { 
         "type":"string", 
         "fielddata":true, 
         "analyzer":"query_analyzer" 
        } 
       } 
      } 
     } 
     } 
    } 
} 

,然後

POST test/log_type/_search 
{ 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "wildcard": { 
      "path.keyword": "/hex/*" 
      } 
     } 
     ] 
    } 
    }, 
    "from": 0, 
    "size": 0, 
    "aggs" : { 
     "genres" : { 
      "terms" : { "field" : "path.no_query" } 
     } 
    } 
} 
查詢