cubicweb-tsfacets


Namecubicweb-tsfacets JSON
Version 0.7.1 PyPI version JSON
download
home_pagehttps://forge.extranet.logilab.fr/cubicweb/cubes/tsfacets
SummaryThis cube implements facets using postgresql text search vectors.
upload_time2024-06-26 14:28:02
maintainerNone
docs_urlNone
authorLOGILAB S.A. (Paris, FRANCE)
requires_pythonNone
licenseLGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Summary
-------
This cube implements facets using postgresql text search vectors.

What does this cube offer ?
---------------------------

This cube defines a new CubicWeb AppObject registry: `tsfacets`.
The base class is `cubicweb_tsfacets.views.TSFacets`; it provides
three methods allowing to recover information to use facets in
a CubicWeb application:

* `get_facets_values_with_count`, which recovers all available facets
  with how many target entities it filters for each value;
* `get_target_entities_count`, which counts target entities taking into
  account the selected facets and possibly a RQL request to restrict
  results;
* `get_target_entities_rset`, which builds a CubicWeb ResultSet taking
  into account the selected facets and possibly a RQL request to restrict
  results.

How to use it ?
---------------

For each group of facets, you have to define a child class of
`cubicweb_tsfacets.views.TSFacets`. Then, you have to complete
the following attributes:

* `key_names_to_rql_definition`: a dictionary linking each facet key 
  with a RQLRequestFacetDef object. A facet key must only contain
  characters, no space, no ".", no "_", etc.
  This object represents a RQL request with the information of if we
  need a mapping table for the value or not. We need a mapping if we
  want to index string with space or other characters like "'";
* `text_search_indexation`: a RQL request returning a list of tuples:
  (target entity eid, text to index for full text search). This
  attribute is optional, and is only used if you want to add
  text search to your result list. Note: this feature will be added in
  an upcoming version;
* `target_etypes`: which entity types are targeted by your facet search;
* `table_name`: the name of the specific postgresql table.

Example of implementation:
--------------------------

In this example, we want to add facets to `Performance` entities.
These facets will be the city, country and theater of the representation,
the date of the representation and the director.

```python
from cubicweb_tsfacets.views import TSFacets, RQLRequestFacetDef


class PerformanceTSFacets(TSFacets):
    __regid__ = "performance_tsfacets"
    table_name = "performance_tsfacets"

    key_names_to_rql_definition = {
        "city": RQLRequestFacetDef("Any X, R Where X representation_city R", True),
        "country": RQLRequestFacetDef("Any X, R Where X representation_country R", True),
        "theater": RQLRequestFacetDef("Any X, R Where X representation_theater R", True),
        "date": RQLRequestFacetDef("Any X, D Where X formatted_start_date D", False),
        "director": RQLRequestFacetDef(
          "Any X, D Where X is Performance, C manifestation X, "
          "C contributor D, C role R, R code 500",
          False
        ),
    }

    target_etypes = {"Performance"}
```

Thus, `CubicWeb-TSFacets` will provide the methods we will need to
build our interface.

            

Raw data

            {
    "_id": null,
    "home_page": "https://forge.extranet.logilab.fr/cubicweb/cubes/tsfacets",
    "name": "cubicweb-tsfacets",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "LOGILAB S.A. (Paris, FRANCE)",
    "author_email": "contact@logilab.fr",
    "download_url": "https://files.pythonhosted.org/packages/e2/bf/74ef1c4b713f9765c42598a5736ffb994164c71114a2c7688d842b093cc1/cubicweb_tsfacets-0.7.1.tar.gz",
    "platform": null,
    "description": "Summary\n-------\nThis cube implements facets using postgresql text search vectors.\n\nWhat does this cube offer ?\n---------------------------\n\nThis cube defines a new CubicWeb AppObject registry: `tsfacets`.\nThe base class is `cubicweb_tsfacets.views.TSFacets`; it provides\nthree methods allowing to recover information to use facets in\na CubicWeb application:\n\n* `get_facets_values_with_count`, which recovers all available facets\n  with how many target entities it filters for each value;\n* `get_target_entities_count`, which counts target entities taking into\n  account the selected facets and possibly a RQL request to restrict\n  results;\n* `get_target_entities_rset`, which builds a CubicWeb ResultSet taking\n  into account the selected facets and possibly a RQL request to restrict\n  results.\n\nHow to use it ?\n---------------\n\nFor each group of facets, you have to define a child class of\n`cubicweb_tsfacets.views.TSFacets`. Then, you have to complete\nthe following attributes:\n\n* `key_names_to_rql_definition`: a dictionary linking each facet key \n  with a RQLRequestFacetDef object. A facet key must only contain\n  characters, no space, no \".\", no \"_\", etc.\n  This object represents a RQL request with the information of if we\n  need a mapping table for the value or not. We need a mapping if we\n  want to index string with space or other characters like \"'\";\n* `text_search_indexation`: a RQL request returning a list of tuples:\n  (target entity eid, text to index for full text search). This\n  attribute is optional, and is only used if you want to add\n  text search to your result list. Note: this feature will be added in\n  an upcoming version;\n* `target_etypes`: which entity types are targeted by your facet search;\n* `table_name`: the name of the specific postgresql table.\n\nExample of implementation:\n--------------------------\n\nIn this example, we want to add facets to `Performance` entities.\nThese facets will be the city, country and theater of the representation,\nthe date of the representation and the director.\n\n```python\nfrom cubicweb_tsfacets.views import TSFacets, RQLRequestFacetDef\n\n\nclass PerformanceTSFacets(TSFacets):\n    __regid__ = \"performance_tsfacets\"\n    table_name = \"performance_tsfacets\"\n\n    key_names_to_rql_definition = {\n        \"city\": RQLRequestFacetDef(\"Any X, R Where X representation_city R\", True),\n        \"country\": RQLRequestFacetDef(\"Any X, R Where X representation_country R\", True),\n        \"theater\": RQLRequestFacetDef(\"Any X, R Where X representation_theater R\", True),\n        \"date\": RQLRequestFacetDef(\"Any X, D Where X formatted_start_date D\", False),\n        \"director\": RQLRequestFacetDef(\n          \"Any X, D Where X is Performance, C manifestation X, \"\n          \"C contributor D, C role R, R code 500\",\n          False\n        ),\n    }\n\n    target_etypes = {\"Performance\"}\n```\n\nThus, `CubicWeb-TSFacets` will provide the methods we will need to\nbuild our interface.\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "This cube implements facets using postgresql text search vectors.",
    "version": "0.7.1",
    "project_urls": {
        "Homepage": "https://forge.extranet.logilab.fr/cubicweb/cubes/tsfacets"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0eda9ce28d60a0e480ad0c6d5801bb0f115a5000f3bbc033de1795a9cf23439d",
                "md5": "5087a86701215844d1812d130eb8b3a1",
                "sha256": "724b8fe22c1611f9b1e0bd9b7d08df82e6c9c7cadf7b80dddfc9257edcd9b45e"
            },
            "downloads": -1,
            "filename": "cubicweb_tsfacets-0.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5087a86701215844d1812d130eb8b3a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14680,
            "upload_time": "2024-06-26T14:28:00",
            "upload_time_iso_8601": "2024-06-26T14:28:00.720167Z",
            "url": "https://files.pythonhosted.org/packages/0e/da/9ce28d60a0e480ad0c6d5801bb0f115a5000f3bbc033de1795a9cf23439d/cubicweb_tsfacets-0.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2bf74ef1c4b713f9765c42598a5736ffb994164c71114a2c7688d842b093cc1",
                "md5": "56d6c404e264a7e1ce3162bb2ab5c7c9",
                "sha256": "5b1c2887d1452dcf88fea2ec9a4fdc27b296529b98f9dbc8b99620cf4e9778f2"
            },
            "downloads": -1,
            "filename": "cubicweb_tsfacets-0.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "56d6c404e264a7e1ce3162bb2ab5c7c9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12723,
            "upload_time": "2024-06-26T14:28:02",
            "upload_time_iso_8601": "2024-06-26T14:28:02.249082Z",
            "url": "https://files.pythonhosted.org/packages/e2/bf/74ef1c4b713f9765c42598a5736ffb994164c71114a2c7688d842b093cc1/cubicweb_tsfacets-0.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-26 14:28:02",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cubicweb-tsfacets"
}
        
Elapsed time: 0.25759s