Package: collective.elastic.plone
OpenSearch or ElasticSearch Integration for Plone content.It consists of these parts:indexer passing content to a separate runningcollective.elastic.ingestservice.catalog index acting as a proxy to Open-/ElasticSearch, integrates with ZCatalog. I.e. use as drop-in replacement forSearchableTextindex.custom plugins forplone.restapito provide structural information for the ingestion serviceREST API endpoint@kitsearchaccepting Open-/ ElasticSearch query returning results with Plone permission check.Table of ContentsInstallationPreconditionsmxdev/mxmakeBuildoutExtra requirementsAfter StartupVolto FrontendConfigurationEnvironmentProxy-indexSource CodeContributionsLicenseInstallationPreconditionsYou need a workingcollective.elastic.ingest(version 2.x) service running.
This implies a running Redis instance and a running Open- xor ElasticSearch instance.mxdev/mxmakeAddcollective.elastic.plone[redis,opensearch]>=2.0.0b11to yourrequirements.txt(alternatively use aconstraints.txtfor version pinning).The extra requirements are needed for the queue server and index server used and may vary, see below.
Alternatively add it to yourpyproject.tomlas dependencies (or in case of legacy code tosetup.[py|cfg]).Provide andsourcean environments variable file (i.e..env) in your backend directory before Plone startup with:export INDEX_SERVER=localhost:9200
export INDEX_USE_SSL=1
export INDEX_OPENSEARCH=1
export INDEX_LOGIN=admin
export INDEX_PASSWORD=admin
export INDEX_NAME=plone
export CELERY_BROKER=redis://localhost:6379/0BuildoutInstallcollective.elastic.plone[redis,opensearch]by adding it to your buildout.
The extra requirements are needed for the queue server and index server used may vary, see below.
Environment may vary too.
Also, see below.[buildout]

# ...

eggs =
    # ...
    collective.elastic.plone[redis,opensearch]

environment-vars +=
    INDEX_SERVER=localhost:9200
    INDEX_USE_SSL=1
    INDEX_OPENSEARCH=1
    INDEX_LOGIN=admin
    INDEX_PASSWORD=admin
    INDEX_NAME=plone
    CELERY_BROKER=redis://localhost:6379/0

[versions]
collective.elastic.plone = 2.0.0and runbin/buildoutExtra requirementsDepending on the queue server and index server used, the extra requirements vary:queue server:redisorrabbitmq.index server:opensearchorelasticsearch.After StartupAfter startup you need to install the addon in Plone via the Addons control panel.
This replaces the SearchableText index with the proxy index and a minimal configuration.
Best is to alter the configuration to the projects needs.
To index all content a manual re-index of the catalog is needed.Volto FrontendThe proxy index works out of the box in Volto.However, in Volto a direct (and much faster) search is possible by using the@kitsearchendpoint, bypassing the catalog.
The endpoint takes a native Open-/ ElasticSearch query and returns the results with Plone permission check.The Volto add-onvolto-searchkit-block(based onreact-searchkit) provides a configurable block using this endpoint.Remark:
For security reasons, in collective.elastic.plone 2.0.0 the@kitsearchendpoint always overrides any “API URL” and “API index” settings with the configured values from the environment.ConfigurationGlobal configuration is done via environment variables.Each catalog proxy-index has its distinct JSON configuration.EnvironmentEnvironment variables are:INDEX_SERVERThe URL of the ElasticSearch or OpenSearch server.Default: localhost:9200INDEX_NAMEThe name of the index to use at the ElasticSearch or OpenSearch service.Default: ploneINDEX_USE_SSLWhether to use a secure connection or not.Default: 0INDEX_OPENSEARCHWhether to use OpenSearch or ElasticSearch.Default: 1INDEX_LOGINUsername for the ElasticSearch 8+ or OpenSearch 2 server.
For the Plone addon read access is enough.Default: adminINDEX_PASSWORDPassword of the above userDefault: adminCELERY_BROKERThe broker URL for Celery.
Seedocs.celeryq.devfor details.Default:redis://localhost:6379/0Proxy-indexThrough-the-web, the proxy-index can be configured in the Zope Management Interface (ZMI) underportal_catalog, then click on theElasticSearchProxyIndex(i.e.SearchableText).In the file system it can be configured as any other index in theportal_catalogtool using a GenericSetup profile and placing acatalog.xmlfile in there.
The index configuration looks like so:<indexmeta_type="ElasticSearchProxyIndex"name="SearchableText"><querytemplate>{"query":{"multi_match":{"query":"{{keys[0]}}","fields":["title*^1.9","description*^1.5","text.data*^1.2","blocks_plaintext*^1.2""file__extracted.content*"],"analyzer":"{{analyzer}}","operator":"or","fuzziness":"AUTO","prefix_length":1,"type":"most_fields","minimum_should_match":"75%"}}}</querytemplate></index>It uses Jinja2 templates to inject the search term into the query.
Available variables are:keysa list of search terms, usually just one.languagethecurrent languageof the portal.analyzerthe name of the analyzer for the query based on the language.
This is hardcoded by now. If there is no analyzer for the language, thestandardanalyzer is used.The resulting query needs to be a validOpenSearch Query DSLorElasticSearch Query DSLtext.Source CodeThe sources are in a GIT DVCS with its main branches atgithub.
There you can report issue too.We’d be happy to see many forks and pull-requests to make this addon even better.Maintainers areJens Klein,Peter Holzerand the BlueDynamics Alliance developer team.
We appreciate any contribution and if a release is needed to be done on PyPI, please just contact one of us.
We also offer commercial support if any training, coaching, integration or adaptions are needed.Releases are done using the Github Release feature and PyPI trusted publishing.
Never use a different release process!
If in doubt ask Jens.ContributionsIdea and testing: Peter HolzerInitial concept & code by Jens W. Klein (Github: @jensens)Contributors:Katja Süss (Github: @ksuess)LicenseThe project is licensed under the GPLv2.