Giter Site home page Giter Site logo

netzkolchose / elastipy Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 6.95 MB

python elasticsearch query module for easily accessing nested aggregations and such

License: Other

Python 100.00%
analytics backend console elasticsearch elasticsearch-queries nested-aggregations pandas-dataframe

elastipy's People

Contributors

defgsus avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

elastipy's Issues

elasticsearch v8 support

ES 8 comes with security by default which is a bit annoying because it's not well documented how to tune the Elasticsearch python client.

However! First try to make the unittests pass by disabling security for the ES 8 node

wrongly structured compound queries

Below is an example of an elastipy query that is written out for clarity. Usually it's created generative via for-loops.

In any case, it does not create the expected query DSL.

from elastipy import Search, query

Search() & (
    (
        ~query.Term("channel_id", "channel-1")
        | query.Range("timestamp", gte="2021-01-01")
    )
    & (
        (
            query.Term("channel_id", "channel-1")
            & query.Term("fulfillment_by", "self")
        ) 
        | (
            query.Term("channel_id", "channel-1")
            & query.Term("fulfillment_by", "other")
        )
    )
)

e.g. the above results in

{
  "bool": {
    "must": [
      {
        "match_all": {}
      },
      {
        "bool": {
          "should": [
            {
              "bool": {
                "must_not": [
                  {
                    "term": {
                      "channel_id": {
                        "value": "channel-1"
                      }
                    }
                  }
                ]
              }
            },
            {
              "range": {
                "timestamp": {
                  "gte": "2021-01-01"
                }
              }
            },
            {
              "bool": {
                "must": [
                  {
                    "term": {
                      "channel_id": {
                        "value": "channel-1"
                      }
                    }
                  },
                  {
                    "term": {
                      "fulfillment_by": {
                        "value": "self"
                      }
                    }
                  }
                ]
              }
            },
            {
              "bool": {
                "must": [
                  {
                    "term": {
                      "channel_id": {
                        "value": "channel-1"
                      }
                    }
                  },
                  {
                    "term": {
                      "fulfillment_by": {
                        "value": "other"
                      }
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
}

KeyError in Aggregation.dict_rows()

using parking-data export:

(search().terms("place_id", valid_place_ids)
    .agg_terms("place",field="place_id", size=1000)
    .agg_date_histogram("week", calendar_interval="week")
    .metric_avg("free", field="num_free")
    .pipeline_derivative("grad", buckets_path="free")
    .execute()
    .dict_rows()
)

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.