def dates(self, field_name, kind, order='<STR_LIT>'):
assert kind in ("<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"),"<STR_LIT>"<EOL>assert order in ('<STR_LIT>', '<STR_LIT>'),"<STR_LIT>"<EOL>search= self._build_search()<EOL>search.facet.reset()<EOL>search.facet.add_date_facet(name=field_name.replace("<STR_LIT>", "<STR_LIT:.>"),<EOL>field=field_name, interval=kind)<EOL>search.agg.reset()<EOL>search.agg.add_date_agg(name=field_name.replace("<STR_LIT>", "<STR_LIT:.>"),<EOL>field=field_name, interval=kind)<EOL>search.size=<NUM_LIT:0><EOL>resulset = get_es_connection(self.es_url, self.es_kwargs).search(search, indices=self.index, doc_types=self.type)<EOL>resulset.fix_aggs()<EOL>entries = []<EOL>for val in resulset.aggs.get(field_name.replace("<STR_LIT>", "<STR_LIT:.>")).get("<STR_LIT>", []):<EOL><INDENT>if "<STR_LIT:time>" in val:<EOL><INDENT>entries.append(val["<STR_LIT:time>"])<EOL><DEDENT><DEDENT>if order=="<STR_LIT>":<EOL><INDENT>return sorted(entries)<EOL><DEDENT>return sorted(entries, reverse=True)<EOL>
Returns a list of datetime objects representing all available dates for
the given field_name, scoped to 'kind'.