Git Product home page Git Product logo

elastic_helper's Introduction

elastic_helper

Two simple functions

  • One used to convert an elastic search collection into a dataframe. See the code for the various parameters.
  • One used to convert a dataframe into an elastic search collection

Installation

pip install elastic-helper

the pypi page (https://pypi.org/project/elastic-helper/):

Example Elastic To Pandas

Parameters

  • es -- The elastic connection object
  • index -- The elastic index
  • query -- (optional) The elastic query in lucene format Example: "module: *"
  • start -- (optional) The time range start if any
  • end -- (optional) The time range start if any
  • timestampfield -- (optional) The timestamp field used by the start and stop parameters
  • datecolumns -- (optional) A collection of columns that must be converted to dates
  • scrollsize -- (optional) The size of the scroll to use
  • size -- (optional) The maximum number of records to retrieve
  • _source -- (optional) The fields to retrieve
from elastic_helper import es_helper 

dataframe=es_helper.elastic_to_dataframe(es,index="docker_stats*"
                                ,_source=['read', 'cpu_percent', 'name']
                                ,datecolumns=["read"]
                                ,timestampfield="read"
                                ,start=datetime.now()-timedelta(hours=1)
                                ,end=datetime.now())                                                               

Example Pandas To Elastic

  • Use an _index column in the dataframe to specify the target index
  • Use an _id column in the dataframe to specify the id
from elastic_helper import es_helper 

es_helper.dataframe_to_elastic(es,my_df)                                                               

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.