Skip to content

Clarify the usage of license and license_type in API search params #3264

Open

Description

Problem

The license filter parameter accepts a comma-separated list of licenses.
The license_type filter parameter accepts comma-separated list of items like all, all-cc, commercial, and modification. These values are then converted into a list of the licenses that correspond to this category. For instance, license_type=commercial,modification URL search filter will be converted to ['by', 'sampling+', 'by-sa', 'cc0', 'pdm'] (excluding all of the ND and NC licenses).

Both of these filters are then converted to 2 separate ES terms queries: one with the list from license parameter, and another with the list of license_type values.

What should happen in an edge case when the user specifies a license that is outside of the specified license type? For instance, license=by-nd&license_type=commercial,modification that will create the following query:

"filter": [
        {
          "terms": {
            "license": ["by-nd"]
          }
        },
        {
          "terms": {
            "license": ["by", "sampling+", "by-sa", "cc0", "pdm"]
          }
        }
      ]

This query (https://api.openverse.engineering/v1/images/?format=json&license=by-nd&license_type=commercial,modification&page_size=1) will not return any results because the license queries are mutually exclusive.

@WordPress/openverse-maintainers, should we return an error response with a message that the license and license_type parameters are incompatible? Or should we just add a note to the API documentation, and keep returning an empty result as we do now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    ✨ goal: improvementImprovement to an existing user-facing feature💬 talk: discussionOpen for discussions and feedback💻 aspect: codeConcerns the software code in the repository📄 aspect: textConcerns the textual material in the repository🟩 priority: lowLow priority and doesn't need to be rushed🧱 stack: apiRelated to the Django API🧱 stack: frontendRelated to the Nuxt frontend

    Type

    No type

    Projects

    • Status

      📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions