예제 #1
0
 def get_end_date(self, index):
     my_connector = Es_connector(index=index)
     res = my_connector.search_size(
         {
             "_source": ["@timestamp", "timestamp_ms"],
             "query": {
                 "match_all": {}
             },
             "sort": [{
                 "@timestamp": {
                     "order": "desc"
                 }
             }]
         }, 1)
     return res['hits']['hits'][0]['_source']
예제 #2
0
 def get_event_central_tweets(self,
                              index="test3",
                              main_term="",
                              related_terms=""):
     my_connector = Es_connector(index=index)
     terms = []
     words = main_term + ' '
     for t in related_terms:
         terms.append(
             {"match": {
                 "text": {
                     "query": t['word'],
                     "boost": t['value']
                 }
             }})
         words += t['word'] + " "
     terms.append({"match": {"text": {"query": main_term, "boost": 2}}})
     query = {"sort": ["_score"], "query": {"bool": {"should": terms}}}
     res = my_connector.search_size(query, 1)
     return res