

def query(query_file_name, days=DEFAULT_NUMBER_OF_DAYS, es_url=er.ES_URL, quantity=DEFAULT_MAX_QUANTITY, verbose=False):
    es = er_results.SearchEngine(es_url)
    with open(query_file_name) as f:
        query_file = yaml.load(f.read())
        query = query_file['query']
    r = es.search(query, days=days)
    print(('total hits: %s' % r.hits['total']))
    attributes = {
        
    }
    for hit in r.hits['hits']:
        for (key, value) in hit['_source'].iteritems():
            value_hash = json.dumps(value)
            attributes.setdefault(key, {
                
            }).setdefault(value_hash, 0)
            attributes[key][value_hash] += 1
    analysis = analyze_attributes(attributes)
    for (attribute, results) in sorted(analysis.iteritems()):
        if ((not verbose) and (attribute in IGNORED_ATTRIBUTES)):
            continue
        print(attribute)
        for (percentage, value) in itertools.islice(results, quantity):
            if isinstance(value, list):
                value = ' '.join((unicode(x) for x in value))
            print(('  %d%% %s' % (percentage, value)))

dataset/ETHPy150Open openstack-infra/elastic-recheck/elastic_recheck/cmd/query.py query/original