Coder Social home page Coder Social logo

elasticsearch-document-updater's Introduction

ElasticSearch Bulk Document Updater Script

This Python script is designed to perform bulk Elasticsearch data update operations. It accomplishes the following tasks:

  1. Reads document data from a JSON file.
  2. Parallelizes document updates.
  3. Sends each update operation to Elasticsearch in bulk.

Usage:

  • This script reads document data from a JSON file and performs document updates on Elasticsearch.
  • The JSON file should have the following format:
  {
    "organizationId1": ["requesterId1", "requesterId2", ...],
    "organizationId2": ["requesterId3", "requesterId4", ...],
    ...
  }
  • After the execution, it prints start and end times along with the processing time.

Requirements:

  • Python 3.6 or higher
  • Elasticsearch 7.6.2 or higher
  • requests library for Python
  • result.json file containing the document data to be updated. (This file should be in the same directory as the script)

Generate result.json file:

This query can be used to generate the result.json file from the database.

SELECT json_agg(json_build_array(organization_id, user_ids))
FROM (SELECT au.organization_id, jsonb_agg(DISTINCT au.id) AS user_ids
      FROM ticket t
               LEFT JOIN app_user au ON t.requester_id = au.id
      WHERE au.organization_id IS NOT NULL
      GROUP BY au.organization_id
      ) subquery;

How to run:

  • Install the requests and argparse libraries for Python.
    • or run the following command:
    • pip install -r requirements.txt
  • Run the script with the following command:
    • tenantId: The tenantId to be updated.
    • env: The environment to be updated.
python script.py --tenantId develop --env local

Don't forget to update environment_addresses for each environment address.

elasticsearch-document-updater's People

Contributors

ugurcandede avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.