123456789101112131415161718192021222324252627282930313233 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- @author: Deepcold
- @file: esQuery.py
- @time: 2019/8/5 14:59
- """
- from elasticsearch import helpers, Elasticsearch
- from manage import CONFIG
- def es_query(query, index, doc_type):
- es_client = Elasticsearch(
- [CONFIG.ES_INFO.HOST], http_auth=(CONFIG.ES_INFO.USER, CONFIG.ES_INFO.PASSWD), port=CONFIG.ES_INFO.PORT,
- use_ssl=False, timeout=40)
- es_result = helpers.scan(client=es_client, query=query, scroll='10h',
- index=index, doc_type=doc_type, timeout='1m')
- return es_result
- def es_query_bg_name(event_company):
- query = {
- "query": {"bool": {
- "must": [
- {"match_phrase": {"yishen_bg": event_company}},
- {"term": {"end_susong_result": {"value": "胜"}}}],
- "must_not": [
- {"term": {"zhixing_result": {"value": "1"}}}]}}
- }
- query_content = es_query(query, "case_connect", "case_connect_type")
- return query_content
|