Builds OpenSearch boolean/filter queries for PyPI package search, supporting term matching, classifier filters, and result ordering. Reuse when implementing faceted search over package metadata.
# Source: https://github.com/pypi/warehouse | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
# SPDX-License-Identifier: Apache-2.0
import re
from opensearchpy import Q
SEARCH_FIELDS = [
"author",
"author_email",
"description",
"download_url",
"home_page",
"keywords",
"license",
"maintainer",
"maintainer_email",
"normalized_name",
"platform",
"summary",
]
SEARCH_BOOSTS = {
"name": 10,
"normalized_name": 10,
"description": 5,
"keywords": 5,
"summary": 5,
}
SEARCH_FILTER_ORDER = (
"Framework",
"Topic",
"Development Status",
"License",
"Programming Language",
"Operating System",
"Environme
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key