-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathestest.py
More file actions
64 lines (54 loc) · 1.7 KB
/
estest.py
File metadata and controls
64 lines (54 loc) · 1.7 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
54
55
56
57
58
59
60
61
62
63
64
import esAccount as esAcc
from elasticsearch import Elasticsearch
from ssl import create_default_context
# context = create_default_context(Purpose.CLIENT_AUTH)
ES = Elasticsearch(
[esAcc.host],
http_auth=(esAcc.id, esAcc.password),
scheme="https",
port=19200,
# use_ssl=False,
verify_certs=False,
# ssl_context=context
)
# print(ES.info())
print(ES.cat.indices())
index = 'kubic_paper'
request= {}
request['page'] = 1
request['numOfCnt'] = 100
if request['page'] < 100:
query = {
"from" : request['page'] * request['numOfCnt'] +1,
"size": int(request['numOfCnt']),
# "sort": [
# {"post_date.keyword": {"order":"asc"}},
# {"post_title.keyword": {"order":"asc"}}
# ]
}
response = ES.search(index=esAcc.index, body=query)
# else:
# request['page']
# print(response['hits']['hits'])
print(response)
# response = ES.search(index=index, body={})
# response = ES.search(index=index, body={
# "query": {
# "bool": {
# "must": [
# { "match": { "post_title": "북핵"} },
# { "bool":{
# "should": [
# # {"match": {"post_body": request['keyInBody']}},
# # {"match": {"post_writer": request['writer'] }},
# # {"match": {"published_institution": request['institution'] }},
# # {"match": {"top_category": request['category'] }},
# ]
# }
# }
# ],
# # "filter": [{"range": { "post_date": { "gte": request['startDate'], "lte": request['endDate'] }}}]
# }
# }
# })
# print(response)