Commit 948e7eff authored by Maria  Di Girolamo's avatar Maria Di Girolamo
Browse files

test to solve conflict with merge

parent 7581b60c
Pipeline #16122 passed with stage
in 1 minute and 33 seconds
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import requests
# import the elasticsearch client library
from elasticsearch import Elasticsearch
# import Python's json library to format JSON responses
import json, time
# use codecs to open the existing HTML file
import codecs
import traceback
import csv
from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
# globals for the Elasticsearch domain
# ResourceWarning: unclosed <socket.socket> error if HTTP in domain
DOMAIN = "localhost"
ELASTIC_PORT = 9200
#BOTTLE_PORT = 1234
# create a timestamp using the time() method
start_time = time.time()
# keep track of the number of the documents returned
doc_count = 0
#URL = "http://localhost:9200/knowledgebase/_search/?_source=projectName&pretty=true"
URL = "http://localhost:9200/knowbase/_search"
#URL = "http://localhost:9200/knowbase/_search/?_source=projectName,topic,label,programmingLanguage"
INDEX = "knowbase"
r = requests.post(URL)
#print("z = r.json()")
z = r.json()
#print(z)
#print("========")
i = 0
for k in z :
#print(k)
doc = {
'know': r.json(),
'timestamp': datetime.now(),
}
res = es.index(index=INDEX, id=i, body=doc)
#print("======res[result]=============")
#print(res['result'])
#print("=========res['source']==========")
res = es.get(index=INDEX, id=i)
#print(res['_source'])
i = i + 1
#print("knowledgebase refresh")
es.indices.refresh(index=INDEX)
query_all = {'size':10000, 'query': {'match_all': {}}}
res = es.search(index="knowbase", body=query_all)
#res = es.search(index=INDEX, body={"query": {"match_all": {}}})
print(res['hits']['total']['value'])
try:
for hit in res['hits']['hits']:
print("PROJECT NAME: ",hit["_source"]['projectName'])
#print(" - TOPIC: ",hit["_source"]['topic'], " - LABEL: ",hit["_source"]['label'])
except:
pass
print("Got %d Hits " % res['hits']['total']['value'])
print("the end")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment