-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_es_server_connection.py
33 lines (26 loc) · 1.03 KB
/
test_es_server_connection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from elasticsearch_reader import ElasticReader
if __name__ == "__main__":
import argparse
argp = argparse.ArgumentParser()
argp.add_argument('--es-port',
dest='es_port',
help='elasticsearch server port',
default=9200)
argp.add_argument('--es-host',
dest='es_host',
help='elasticsearch server host name',
default='localhost')
argp.add_argument('--es-index',
dest='es_index',
help='elasticsearch index name to get data from',
default='tweets')
argp.add_argument('--date',
help='start date to get data from',
required=True)
args = argp.parse_args()
es_reader = ElasticReader(args.es_host, args.es_port, args.es_index)
ids = es_reader.read_all_ids(args.date)
if len(ids) > 0:
print("ES CONNECTION TEST: OK")
else:
print("ES CONNECTION TEST: NOK")