Skip to main content

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.

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.

Release files for cubicweb-tsfacets 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cubicweb-tsfacets 0.7.1
File Size Uploaded
cubicweb_tsfacets-0.7.1.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cubicweb-tsfacets 0.7.1
File Interpreter ABI Platform
cubicweb_tsfacets-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.4 kB

Release files / cubicweb_tsfacets-0.7.1.tar.gz

Download URL cubicweb_tsfacets-0.7.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5b1c2887d1452dcf88fea2ec9a4fdc27b296529b98f9dbc8b99620cf4e9778f2
BLAKE2b-256 checksum
How to use checksums
e2bf74ef1c4b713f9765c42598a5736ffb994164c71114a2c7688d842b093cc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / cubicweb_tsfacets-0.7.1-py3-none-any.whl

Download URL cubicweb_tsfacets-0.7.1-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
724b8fe22c1611f9b1e0bd9b7d08df82e6c9c7cadf7b80dddfc9257edcd9b45e
BLAKE2b-256 checksum
How to use checksums
0eda9ce28d60a0e480ad0c6d5801bb0f115a5000f3bbc033de1795a9cf23439d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page