diff --git a/docs/index.rst b/docs/index.rst --- a/docs/index.rst +++ b/docs/index.rst @@ -26,6 +26,7 @@ :caption: Contents: cli + query-language Reference Documentation ----------------------- diff --git a/docs/query-language.rst b/docs/query-language.rst new file mode 100644 --- /dev/null +++ b/docs/query-language.rst @@ -0,0 +1,177 @@ +Search Query Language +===================== + + +Every query is composed of filters separated by ``&&`` or ``||`` +which represent AND and OR respectively. These filters have +3 components in the order : ``Name Operator Value`` + +**Note:** Whitespaces are optional between the three components of a filter. + +Some of the examples are : + * ``origin = django && language in [python] && visits >= 5`` + * ``last_revision > 2020-01-01 limit = 10`` + * ``last_visit > 2021-01-01 || last_visit < 2020-01-01`` + * ``visited = false && metadata = "gitlab"`` + * ``keyword in ["orchestration", "kubectl"] && language in [go, rust]`` + * ``visit_type = [deb] && license in ["GPL-3"]`` + + +The filters have been classfied based on the type of the value that it expects. + + +Pattern filters +--------------- + + * Name: ``origin`` ``metadata`` + * Operator: ``=`` + * Value: String wrapped in quotation marks(``"`` or ``'``) + +**Note:** If the string has no whitespace then the quotation marks become optional. + +**Examples:** + + * ``origin = https://github.com/Django/django`` + * ``origin = kubernetes`` + * ``origin = "github python"`` + * ``metadata = orchestration`` + * ``metadata = "javascript language"`` + +Boolean filters +--------------- + + + * Name: ``visited`` + * Operator: ``=`` + * Value: ``true`` or ``false`` + +**Examples:** + + * ``visited = true`` + * ``visited = false`` + + +Numeric filters +--------------- + + * Name: ``visits`` + * Operator: ``<`` ``<=`` ``=`` ``!=`` ``>`` ``>=`` + * Value: Positive integer + +**Examples:** + + + * ``visits > 2`` + * ``visits = 5`` + * ``visits <= 10`` + + +Un-bounded List filters +----------------------- + +Returns origins that satisfy the criteria based on a given list + + * Name: + * ``language`` : Programming languages used + * ``license`` : License used + * ``keyword`` : Keywords(tags) + Description(includes README) of the repository + * Operator: ``in`` ``not in`` + * Value: Array of strings + +**Note:** If string has no whitespace then the quotation marks become optional. + +**Examples:** + + * ``language in [python, js]`` + * ``license in ["GPL 3.0 or later", MIT]`` + * ``keyword in ["Software Heritage", swh]`` + + +Bounded List filters +-------------------- + +Returns origins that satisfy the criteria based on a list of fixed options + + **visit_type** + + * Name: ``visit_type`` : Returns only origins with at least one of the specified visit types + * Operator: ``=`` + * Value: Array of the following values + + ``any`` + ``cran`` + ``deb`` + ``deposit`` + ``ftp`` + ``hg`` + ``git`` + ``nixguix`` + ``npm`` + ``pypi`` + ``svn`` + ``tar`` + + **sort_by** + + * Name: ``sort_by`` : Sorts origins based on the given list of origin attributes + * Operator: ``=`` + * Value: Array of the following values + + ``visits`` + ``last_visit`` + ``last_eventful_visit`` + ``last_revision`` + ``last_release`` + ``created`` + ``modified`` + ``published`` + +**Examples:** + + + * ``visit_type = [svn, npm]`` + * ``visit_type = [nixguix, "ftp"]`` + * ``sort_by = ["last_visit", created]`` + * ``sort_by = [visits, modified]`` + +Date filters +------------ + +Returns origins having their date type values in the given range + + * Name: + + * ``last_visit`` : Latest visit date + * ``last_eventful_visit`` : Latest visit date when a new snapshot was detected + * ``last_revision`` : Latest commit date + * ``last_release`` : Latest release date + * ``created`` Creation date + * ``modified`` Modification date + * ``published`` Published date + + * Operator: ``<`` ``<=`` ``=`` ``!=`` ``>`` ``>=`` + * Value: Date in ``Standard ISO`` format + + **Note:** Last three date filters are based on metadata which has to be manually entered + by the repository authors and hence it might not be correct or up-to-date. + +**Examples:** + + * ``last_visit > 2001-01-01 && last_visit < 2101-01-01`` + * ``last_revision = "2000-01-01 18:35Z"`` + * ``last_release != "2021-07-17T18:35:00Z"`` + * ``created <= "2021-07-17 18:35"`` + +Limit filter +------------ + +Limits the number of results to at most N + + * Name: ``limit`` + * Operator: ``=`` + * Value: Positive Integer + +**Examples:** + + * ``limit = 1`` + * ``limit = 15``