Esempio n. 1
0
def from_type_name(name: str) -> Union[datastore.Entity, None]:
    """
    Gets a DeviceDataType entity from the datastore using
        the type name.
    :param name:
    :return:
    """
    q = client.query(kind='DeviceDataType')
    q.add_filter('type_name', '=', name)
    return q.fetch(1)
Esempio n. 2
0
def analytics():
    query = {
        'size': 0,
        'query': {
            'match_all': {}
        },
        'facets': {
            'country': {
                'terms': {
                    'field': 'Census Country',
                    'size': 500
                }
            },
            'dataset': {
                'terms': {
                    'field': 'Dataset',
                    'size': 15
                }
            }
        }
    }
    out = client.query(query)
    import pprint
    pprint.pprint(out)
Esempio n. 3
0
def analytics():
    query = {
        'size': 0,
        'query': {
            'match_all': {}
        },
        'facets': {
            'country': {
                'terms': {
                    'field': 'Census Country',
                    'size': 500
                }
            },
            'dataset': {
                'terms': {
                    'field': 'Dataset',
                    'size': 15
                }
            }
        }
    }
    out = client.query(query)
    import pprint
    pprint.pprint(out)
Esempio n. 4
0
import datastore.client, pprint, json

url = "http://localhost:9200/esfera/discursos/"
client = datastore.client.DataStoreClient(url)

query = {
    "query" : {
        "match_all" : {}
        },
    "size":10,
    "from":0,
    "filter":[
        {"term":
            {"partido":"UDN"}
        }]
}

try:
    out = client.query(query)
    pprint.pprint(out)
except:
    print  "Error"
    print url + "_search?source=" + json.dumps(query)
Esempio n. 5
0
def get_last_dataframes(device_id: int, n: int = 1):
    key = Key("Device", device_id)
    device = client.get(key)

    q = client.query(kind="DeviceData")
    q.add_filter("device_key", "=", device.key)