0
所以我試圖在字段「svctag」中獲取所有帶有重複數據的文檔。使用Kibana在ES上查詢
我對此做了以下查詢。
"aggs": { "svctag": { "terms": { "field": "svctag","size": 0, "min_doc_count": 2}}}
我也試着用它運行它,仍然得到了同樣的錯誤。
{"aggs": {"duplicateNames": {"terms": { "field": "svctag","size": 0, "min_doc_count": 2}}}}
但是在運行這個,我得到以下錯誤。
Error: Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"query_parsing_exception","reason":"Failed to parse query [\"aggs\": { \"svctag\": { \"terms\": { \"field\": \"svctag\",\"size\": 0, \"min_doc_count\": 2}}}]","index":"logstash-data","line":1,"col":430}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"logstash-data","node":"PDjSn1G3SYS7jgGLRBV2HQ","reason":{"type":"query_parsing_exception","reason":"Failed to parse query [\"aggs\": { \"svctag\": { \"terms\": { \"field\": \"svctag\",\"size\": 0, \"min_doc_count\": 2}}}]","index":"logstash-data","line":1,"col":430,"caused_by":{"type":"parse_exception","reason":"Cannot parse '\"aggs\": { \"svctag\": { \"terms\": { \"field\": \"svctag\",\"size\": 0, \"min_doc_count\": 2}}}': Encountered \" \":\" \": \"\" at line 1, column 6.\r\nWas expecting one of:\r\n <EOF> \r\n <AND> ...\r\n <OR> ...\r\n <NOT> ...\r\n \"+\" ...\r\n \"-\" ...\r\n <BAREOPER> ...\r\n \"(\" ...\r\n \"*\" ...\r\n \"^\" ...\r\n <QUOTED> ...\r\n <TERM> ...\r\n <FUZZY_SLOP> ...\r\n <PREFIXTERM> ...\r\n <WILDTERM> ...\r\n <REGEXPTERM> ...\r\n \"[\" ...\r\n \"{\" ...\r\n <NUMBER> ...\r\n ","caused_by":{"type":"parse_exception","reason":"Encountered \" \":\" \": \"\" at line 1, column 6.\r\nWas expecting one of:\r\n <EOF> \r\n <AND> ...\r\n <OR> ...\r\n <NOT> ...\r\n \"+\" ...\r\n \"-\" ...\r\n <BAREOPER> ...\r\n \"(\" ...\r\n \"*\" ...\r\n \"^\" ...\r\n <QUOTED> ...\r\n <TERM> ...\r\n <FUZZY_SLOP> ...\r\n <PREFIXTERM> ...\r\n <WILDTERM> ...\r\n <REGEXPTERM> ...\r\n \"[\" ...\r\n \"{\" ...\r\n <NUMBER> ...\r\n "}}}}]}}
我在哪裏出錯了?任何幫助將不勝感激。
非常感謝。這似乎工作。 但我有點懷疑。實際上,我有2個源文件,我從中獲取數據,一個有8個字段,另一個有5個字段。幾乎沒有這些領域是常見的。我在一個索引下存儲。我想檢查源文件2的源文件1和源文件2的字段1中有多少匹配。那麼這種方法對我有幫助嗎? –
是的,通過在'field1'和/或'field2'上使用另一個'terms'子聚合。 – Val
你好。我想我沒有說清楚。我不想知道每種類型有多少,我想要做的只是知道匹配數據點的數量。所以我想要一個總數。現在我正在創造A有2個,B有2個,C有3個,D有1個。但是我在這裏尋找的是3個匹配(因爲有多個A B和C的條目) –