Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajouter /facets/all/<field> #3

Open
dalf opened this issue Apr 22, 2024 · 0 comments
Open

Ajouter /facets/all/<field> #3

dalf opened this issue Apr 22, 2024 · 0 comments
Assignees

Comments

@dalf
Copy link
Member

dalf commented Apr 22, 2024

Implementer /facets/all/<field> pour avoir des stats toutes collections confondues

Une fonction pour fusionner les résultats de get_field_values(collection, field) :

def merge_values(values_list):
    """Take a list of result from get_field_values and merge them into one response
    sorted by doc_count
    """
    total = {}
    for values in values_list:
        for value in values:
            v = total.setdefault(value["key"].capitalize(), {
                "key": value["key"],
                "doc_count": 0,
            })
            v["doc_count"] += value["doc_count"]
    total_list = list(total.values())
    total_list.sort(key=lambda value:value["doc_count"], reverse=True)
    return total_list
@anaismz anaismz self-assigned this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants