def get_first_enriched_date(repository_url):
    """ Retrieve the first/oldest metadata__updated_on of the item
    corresponding to given repository.
    """
    query_first_enriched_date = (
        """
    {
        "size": 0,
        "aggs": {
            "1": {
                "top_hits": {
                    "docvalue_fields": [
                        "metadata__updated_on"
                    ],
                    "_source": "metadata__updated_on",
                    "size": 1,
                    "sort": [{
                        "commit_date": {
                            "order": "asc"
                        }
                    }]
                }
            }
        },
        "query": {
            "bool": {
                "filter": [{
                    "term": {
                        "origin": "%s"
                    }
                }]
            }
        }
    }
    """
         % repository_url)
    return query_first_enriched_date
