Skip to content

Latest commit

 

History

History
343 lines (264 loc) · 10.7 KB

README.rst

File metadata and controls

343 lines (264 loc) · 10.7 KB
Coveralls Latest Version Egg Status

https://img.shields.io/pypi/pyversions/rer.voltoplugin.search.svg?style=plastic:alt:Supported-PythonVersions

License

RER Voltoplugin Search

Add-on for manage Search results in Volto.

Features

  • Control panel in plone registry to manage Search settings.
  • Restapi endpoint that exposes these settings for Volto.

If rer.solrpush is installed and active, the search will be done through SOLR and not Plone catalog.

In results facets there will be also a site_name additional data.

@rer-search endpoint

This endpoint is similar to the original @search one but add an additional information about facets based on this package's settings and results.

facets is a list of filters that can be used to refine the search, and can be configured in the controlpanel.

The first one is always portal_type, followed by the indexes selected in controlpanel.

Example of @rer-search response:

{
    "@id": "http://localhost:8080/Plone/++api++/@rer-search?SearchableText=foo",
    "facets": [
        {
            "index": "group",
            "items": [
                {
                    "id": "all",
                    "items": {},
                    "label": {
                        "it": "Tutti i contenuti (5)"
                    }
                },
                {
                    "advanced_filters": {},
                    "icon": "",
                    "id": "pagine",
                    "label": {
                        "en": "Documents (1)",
                        "it": "Pagine (1)"
                    },
                    "portal_types": [
                        "Document"
                    ]
                },
                {
                    "advanced_filters": {},
                    "icon": "",
                    "id": "notizie",
                    "label": {
                        "en": "News (2)",
                        "it": "Notizie (2)"
                    },
                    "portal_types": [
                        "News Item",
                        "ExternalNews"
                    ]
                },
                {
                    "advanced_filters": {},
                    "icon": "",
                    "id": "bandi",
                    "label": {
                        "en": "Announcements (1)",
                        "it": "Bandi (1)"
                    },
                    "portal_types": [
                        "Bando"
                    ]
                },
                {
                    "advanced_filters": {},
                    "icon": "",
                    "id": "file-e-immagini",
                    "label": {
                        "en": "Files and images (0)",
                        "it": "File e immagini (0)"
                    },
                    "portal_types": [
                        "File",
                        "Image"
                    ]
                },
                {
                    "advanced_filters": [
                        {
                            "index_end": "end",
                            "index_start": "start",
                            "label_end": {
                                "it": "Data di fine"
                            },
                            "label_start": {
                                "it": "Data di inizio"
                            },
                            "type": "DateRangeIndex"
                        }
                    ],
                    "icon": "",
                    "id": "eventi",
                    "label": {
                        "en": "Events (1)",
                        "it": "Eventi (1)"
                    },
                    "portal_types": [
                        "Event"
                    ]
                }
            ],
            "label": {
                "it": "Cosa"
            },
            "type": "Groups"
        },
        {
            "index": "Subject",
            "items": [
                {
                    "label": "aaa (2)",
                    "value": "aaa"
                },
                {
                    "label": "bbb (1)",
                    "value": "bbb"
                }
            ],
            "label": {
                "en": "Keywords",
                "it": "Parole chiave"
            },
            "type": "KeywordIndex"
        }
    ],
    "items": [
        {
            "@id": "http://localhost:8080/Plone/xxx",
            "@type": "Document",
            "UID": "33fe109d445d4e1db4b46afae8301950",
            "description": "",
            "id": "xxx",
            "image_field": "",
            "image_scales": null,
            "review_state": "published",
            "title": "Pagina foo",
            "type_title": "Pagina"
        },
        ...
    ],
    "items_total": 5
}

Advanced filters for groups

In each group types you can select an advanced filter.

Advanced filters are a list of preset filters that allow to add some extra filters when that group is selected in search.

By default there is only one advanced filter called "Events" that add start and end date filters, but you can add more presets in your custom package.

Register new advanced filters

Advanced filters are a list of named adapters, so you can add more and override existing ones if needed.

You just need to register a new named adapter:

<adapter
  factory = ".my_filters.MyNewFilters"
  name= "my-filters"
/>

The adapter should have a label attribute (needed to show a human-readable name in sitesearch-settings view) and return the schema for the additional indexes:

from zope.component import adapter
from zope.interface import implementer
from rer.voltoplugin.search.interfaces import IRERVoltopluginSearchCustomFilters
from zope.interface import Interface
from my.package import _
from zope.i18n import translate


@adapter(Interface, Interface)
@implementer(IRERVoltopluginSearchCustomFilters)
class MyNewFilters(object):
"""
"""

label = _("some_labelid", default=u"Additional filters")

def __init__(self, context, request):
    self.context = context
    self.request = request

def __call__(self):
    return [
        {
            "index": "xxx",
            "items": {},
            "label": {"it": "Inizio", "en": "Start"},
            "type": "DateIndex",
        },
        {
            "index": "yyy",
            "items": {},
            "label": {"it": "Fine", "en": "End"},
            "type": "DateIndex",
        },
    ]

Where xxx and yyy are Plone's catalog indexes.

Vocabularies

rer.voltoplugin.search.vocabularies.AdvancedFiltersVocabulary

Vocabulary that returns the list of registered adapters for custom filters based on content-types.

rer.voltoplugin.search.vocabularies.IndexesVocabulary

Vocabulary that returns the list of available indexes in portal_catalog.

rer.voltoplugin.search.vocabularies.GroupingTypesVocabulary

Vocabulary that returns the list of available portal_types.

If rer.solr is installed, returns the list of portal_types indexed in SOLR, otherwise return ReallyUserFriendlyTypes Plone vocabulary.

Volto integration

To use this product in Volto, your Volto project needs to include a new plugin: https://github.com/collective/XXX

Translations

This product has been translated into

  • Italian

Installation

Install rer.voltoplugin.search by adding it to your buildout:

[buildout]

...

eggs =
    rer.voltoplugin.search

and then running bin/buildout

Contribute

License

The project is licensed under the GPLv2.

Credits

Developed with the support of

Regione Emilia-Romagna

Regione Emilia Romagna supports the PloneGov initiative.

Authors

This product was developed by RedTurtle Technology team.

RedTurtle Technology Site