Interface de recherche dynamique basée sur Elasticsearch avec génération de rapports automatisés

Intermédiaire

Ceci est unDocument Extraction, Multimodal AIworkflow d'automatisation du domainecontenant 11 nœuds.Utilise principalement des nœuds comme Code, FormTrigger, HttpRequest, ReadWriteFile. Interface de recherche dynamique et génération automatisée de rapports avec Elasticsearch

Prérequis
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "3eqTGbhtSxDjuMZC",
  "meta": {
    "instanceId": "5cee0adb1ef2b84ac8a86937fac5115d710898b6c70f9f7c3f3ca3ef70a11bf7",
    "templateCredsSetupCompleted": true
  },
  "name": "Dynamic Search Interface with Elasticsearch and Automated Report Generation",
  "tags": [],
  "nodes": [
    {
      "id": "e3eb30ef-51d9-4cd5-ab1f-807b87e06795",
      "name": "Formulaire de recherche",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        480,
        -220
      ],
      "webhookId": "169f8e1c-e4a8-4229-9b2a-9db33003f221",
      "parameters": {
        "path": "169f8e1c-e4a8-4229-9b2a-9db33003f221",
        "options": {},
        "formTitle": "🔍 Dynamic Search",
        "formFields": {
          "values": [
            {
              "fieldType": "number",
              "fieldLabel": "Minimum Amount ($)"
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Time Range",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Last 1 Hour"
                  },
                  {
                    "option": "Last 6 Hours"
                  },
                  {
                    "option": "Last 24 Hours"
                  },
                  {
                    "option": "Last 3 Days"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Customer ID (Optional)"
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Report Format",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Text Report"
                  },
                  {
                    "option": "CSV Export"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "responseMode": "responseNode",
        "formDescription": "Search for suspicious transactions in your banking database"
      },
      "typeVersion": 2.1
    },
    {
      "id": "79e2a04d-9427-4d8d-ae8a-41005a2ab80d",
      "name": "Construire la requête de recherche",
      "type": "n8n-nodes-base.code",
      "position": [
        700,
        -220
      ],
      "parameters": {
        "jsCode": "// Process form input and build Elasticsearch query\nconst formData = $input.first().json;\n\n// Extract form values\nconst minAmount = formData['Minimum Amount ($)'] || 1000;\nconst timeRange = formData['Time Range'] || 'Last 24 Hours';\nconst customerId = formData['Customer ID (Optional)']?.trim() || null;\nconst reportFormat = formData['Report Format'] || 'Text Report';\n\n// Convert time range to Elasticsearch format\nlet timeRangeES;\nswitch(timeRange) {\n  case 'Last 1 Hour':\n    timeRangeES = 'now-1h';\n    break;\n  case 'Last 6 Hours':\n    timeRangeES = 'now-6h';\n    break;\n  case 'Last 24 Hours':\n    timeRangeES = 'now-24h';\n    break;\n  case 'Last 3 Days':\n    timeRangeES = 'now-3d';\n    break;\n  default:\n    timeRangeES = 'now-24h';\n}\n\n// Build Elasticsearch query\nconst mustConditions = [\n  {\n    \"range\": {\n      \"timestamp\": {\n        \"gte\": timeRangeES\n      }\n    }\n  },\n  {\n    \"range\": {\n      \"amount\": {\n        \"gte\": minAmount\n      }\n    }\n  }\n];\n\n// Add customer filter if provided\nif (customerId) {\n  mustConditions.push({\n    \"term\": {\n      \"customer_id.keyword\": customerId\n    }\n  });\n}\n\nconst esQuery = {\n  \"query\": {\n    \"bool\": {\n      \"must\": mustConditions\n    }\n  },\n  \"sort\": [{ \"timestamp\": { \"order\": \"desc\" } }],\n  \"size\": 100\n};\n\nreturn {\n  elasticsearchQuery: esQuery,\n  searchParams: {\n    minAmount,\n    timeRange,\n    customerId,\n    reportFormat\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "62e186d7-c90f-4576-8c56-d850e784e9e0",
      "name": "Rechercher dans Elasticsearch",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        940,
        -220
      ],
      "parameters": {
        "url": "https://localhost:9220/bank_transactions/_search",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "jsonBody": "={{ $json.elasticsearchQuery }}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth"
      },
      "typeVersion": 4.1
    },
    {
      "id": "4869c996-8a2e-40a1-aea3-384e0e379c14",
      "name": "Formater le rapport",
      "type": "n8n-nodes-base.code",
      "position": [
        1140,
        -220
      ],
      "parameters": {
        "jsCode": "// Get data from previous nodes\nconst esResponse = $input.first().json;\nconst searchParams = $('Build Search Query').first().json.searchParams;\n\n// Extract results\nconst hits = esResponse.hits?.hits || [];\nconst totalFound = esResponse.hits?.total?.value || 0;\n\n// Generate filename\nconst timestamp = new Date().toISOString().split('T')[0];\nconst isCSV = searchParams.reportFormat === 'CSV Export';\nconst filename = `report_${timestamp}.${isCSV ? 'csv' : 'txt'}`;\nconst mimeType = isCSV ? 'text/csv' : 'text/plain';\n\n// Generate report content\nlet reportContent = '';\n\nif (isCSV) {\n  // CSV format\n  reportContent = 'Transaction_ID,Customer_ID,Amount,Merchant_Category,Timestamp\\n';\n  hits.forEach(hit => {\n    const t = hit._source || {};\n    reportContent += `\"${t.transaction_id || ''}\",\"${t.customer_id || ''}\",${t.amount || 0},\"${t.merchant_category || ''}\",\"${t.timestamp || ''}\"\\n`;\n  });\n} else {\n  // Text format\n  reportContent = `DYNAMIC SEARCH REPORT\\n`;\n  reportContent += `======================\\n\\n`;\n  reportContent += `Search Criteria:\\n`;\n  reportContent += `- Minimum Amount: $${searchParams.minAmount}\\n`;\n  reportContent += `- Time Range: ${searchParams.timeRange}\\n`;\n  reportContent += `- Customer: ${searchParams.customerId || 'All'}\\n\\n`;\n  reportContent += `Results: ${totalFound} transactions found\\n\\n`;\n  \n  if (hits.length > 0) {\n    reportContent += `TRANSACTIONS:\\n`;\n    reportContent += `=============\\n\\n`;\n    hits.forEach((hit, index) => {\n      const t = hit._source || {};\n      reportContent += `${index + 1}. Transaction ID: ${t.transaction_id}\\n`;\n      reportContent += `   Customer: ${t.customer_id}\\n`;\n      reportContent += `   Amount: $${t.amount}\\n`;\n      reportContent += `   Merchant: ${t.merchant_category}\\n`;\n      reportContent += `   Time: ${t.timestamp}\\n\\n`;\n    });\n  } else {\n    reportContent += `No suspicious transactions found matching your criteria.\\n`;\n  }\n}\n\n// Convert content to binary data\nconst binaryData = Buffer.from(reportContent, 'utf8');\n\nreturn {\n  json: {\n    filename: filename,\n    mimeType: mimeType,\n    content: reportContent\n  },\n  binary: {\n    data: binaryData\n  }\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "764ac1c5-0ae2-4048-884b-dceb4ea6d719",
      "name": "Lire/Écrire des fichiers sur le disque",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        1320,
        -220
      ],
      "parameters": {
        "options": {},
        "fileName": "=/tmp/{{ $json.filename }}",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "b4c9ae5c-cd17-492e-a543-205329a872b9",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -260
      ],
      "parameters": {
        "width": 360,
        "height": 220,
        "content": "## 🎯 ENTRY POINT\nUser fills out dynamic search form with:\n- Minimum transaction amount\n- Time range (1hr to 3 days)\n- Optional customer ID filter\n- Output format (Text/CSV)\n\n💡 TIP: Form auto-validates required fields!"
      },
      "typeVersion": 1
    },
    {
      "id": "b36fea54-e177-4edc-a091-110b25475ad4",
      "name": "Note adhésive1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        0
      ],
      "parameters": {
        "color": 2,
        "width": 360,
        "height": 300,
        "content": "## 🔧 QUERY BUILDER\nTransforms user input into Elasticsearch query:\n\n✅ Converts time ranges:\n   \"Last 24 Hours\" → \"now-24h\"\n   \"Last 3 Days\" → \"now-3d\"\n\n✅ Builds filters:\n   • Amount >= minimum\n   • Timestamp within range\n   • Customer ID (if provided)\n\n📊 Output: Ready-to-use ES query + metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "8d3f38d7-b483-43cb-bcb5-9524a7a17e86",
      "name": "Note adhésive2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 320,
        "height": 260,
        "content": "## 🎯 DATA HUNTER\nSearches bank_transactions index for suspicious activity\n\n🔧 Configuration:\n   • POST to localhost:9220\n   • Uses HTTP Basic Auth\n   • Sends JSON query from previous node\n   • Returns max 100 results, newest first\n\n⚠️ Note: Requires valid ES credentials!"
      },
      "typeVersion": 1
    },
    {
      "id": "11039177-def0-4de1-ad25-f91e1294abee",
      "name": "Note adhésive3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 340,
        "height": 340,
        "content": "## 📝 REPORT GENERATOR\nTransforms raw ES data into user-friendly reports\n\n🎨 Creates two formats:\n   📄 TEXT: Human-readable summary\n   📊 CSV: Spreadsheet-ready data export\n\n✨ Features:\n   • Auto-generates timestamped filename\n   • Converts text to binary for file writing\n   • Includes search criteria summary\n   • Lists all suspicious transactions\n\n🔄 Output: Content + Binary data ready for file save"
      },
      "typeVersion": 1
    },
    {
      "id": "7c8c7226-a9e3-4edb-9497-e1980f3e84ea",
      "name": "Note adhésive4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        0
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 260,
        "content": "## 📁 FILE SAVER\nWrites the report to server disk\n\n📍 Location: /tmp/report_YYYY-MM-DD.{txt|csv}\n🔧 Uses binary data from Format Report node\n✅ File ready for download or further processing\n\n🎯 Perfect for:\n   • Audit trails\n   • Batch processing\n   • Compliance reporting"
      },
      "typeVersion": 1
    },
    {
      "id": "79d96536-a117-474b-a524-ec0e54f7ae2b",
      "name": "Note adhésive5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -520
      ],
      "parameters": {
        "color": 6,
        "width": 720,
        "height": 200,
        "content": "## 🎯 DYNAMIC SEARCH PIPELINE\n\nUser Form → Query Builder → ES Search → Report Format → File Save\n\n⏱️ Typical execution: 2-5 seconds\n📊 Handles up to 100 suspicious transactions\n🔒 Secure: Uses authenticated ES connection\n📁 Output: Timestamped report files in /tmp/"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "42705d97-c55a-4ebe-8107-536a8c7faea3",
  "connections": {
    "e3eb30ef-51d9-4cd5-ab1f-807b87e06795": {
      "main": [
        [
          {
            "node": "79e2a04d-9427-4d8d-ae8a-41005a2ab80d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4869c996-8a2e-40a1-aea3-384e0e379c14": {
      "main": [
        [
          {
            "node": "764ac1c5-0ae2-4048-884b-dceb4ea6d719",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "79e2a04d-9427-4d8d-ae8a-41005a2ab80d": {
      "main": [
        [
          {
            "node": "62e186d7-c90f-4576-8c56-d850e784e9e0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "62e186d7-c90f-4576-8c56-d850e784e9e0": {
      "main": [
        [
          {
            "node": "4869c996-8a2e-40a1-aea3-384e0e379c14",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - Extraction de documents, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds11
Catégorie2
Types de nœuds5
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
DataMinex

DataMinex

@dataminex

Smart Connection Analysis from Open Data, Globally at Scale

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34