]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
if elasticsearch_version >= 7 we should not send the _type to elasticsearch, deprecat... 4520/head
authorMario Jansen <mario@hosting2go.nl>
Fri, 23 Jun 2023 11:59:50 +0000 (13:59 +0200)
committerMario Jansen <mario@hosting2go.nl>
Fri, 23 Jun 2023 11:59:50 +0000 (13:59 +0200)
src/plugins/lua/elastic.lua

index b93186f9a9300a524aea326565fcb20eae044ad2..ce2d01b80ae80ddc37e7d7c531fe5806344aa3dd 100644 (file)
@@ -57,6 +57,7 @@ local settings = {
   no_ssl_verify = false,
   max_fail = 3,
   ingest_module = false,
+  elasticsearch_version = 6,
 }
 
 local function read_file(path)
@@ -71,8 +72,13 @@ local function elastic_send_data(task)
   local es_index = os.date(settings['index_pattern'])
   local tbl = {}
   for _,value in pairs(rows) do
-    table.insert(tbl, '{ "index" : { "_index" : "'..es_index..
-        '", "_type" : "_doc" ,"pipeline": "rspamd-geoip"} }')
+    if settings.elasticsearch_version >= 7 then
+        table.insert(tbl, '{ "index" : { "_index" : "'..es_index..
+            '","pipeline": "rspamd-geoip"} }')
+    else
+        table.insert(tbl, '{ "index" : { "_index" : "'..es_index..
+            '", "_type" : "_doc" ,"pipeline": "rspamd-geoip"} }')
+    end
     table.insert(tbl, ucl.to_format(value, 'json-compact'))
   end