-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscratchpad.py
More file actions
53 lines (35 loc) · 1.25 KB
/
scratchpad.py
File metadata and controls
53 lines (35 loc) · 1.25 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import time
from elasticsearch import Elasticsearch
from urllib.parse import urlparse
import os
def searchbox_connect():
url = urlparse(os.environ['SEARCHBOX_URL'])
######## test
es = Elasticsearch(
[os.environ['SEARCHBOX_URL']],
http_auth=(url.username, url.password),
scheme=url.scheme,
port=url.port,
)
return es
if __name__ == "__main__":
all_query2 = {
"query": {
"bool" : {
"filter":[{
"bool" : {
"should" : [{"term" : { "source" : "ukhls"}}]
}
},
],
}
}
}
######################################################################################
### Data prep functions
es = searchbox_connect()
r2 = es.search(index="index_var", body=all_query2, size = 1000)
search_results = []
for hit in r2["hits"]["hits"]:
search_results.append([hit["_source"]["source"], hit["_source"]["table"], hit["_source"]["variable_name"], hit["_source"]["variable_description"]])
print(search_results)