Package: kitconcept.solr
kitconcept.solrAn opinionated Solr integration for PloneFeatureskitconcept.solris an opinionated Solr integration package for Plone sites. It leverages (and depends on)collective.solr, by adding a new endpoint@solrthat supports search requests with facetted results.Endpointsnamecontext@solrPlone site or Folderish contentUsing the@solrendpointThe@solrendpoint is used from thekitconcept.volto-solrVolto add-on package for the implementation of the site search. It can also be used for custom components. The parameters roughly follow the parameters of the normal site search service, but differ in some respects.TBDgive more information about this.For now, please refer to the source code of thesolr.pymodule, in case you want to use for your own purposes.DocumentationInstallationAddkitconcept.solras a dependency on your package'ssetup.pyinstall_requires=["kitconcept.solr","Plone","plone.restapi","setuptools",],Also, addkitconcept.solrto your package'sconfigure.zcml(ordependencies.zcml):<includepackage="kitconcept.solr"/>Remark with Plone 6.0With Plone 6.0 you must add an additional dependency"plone.restapi>=8.40.0".The package also keeps support with Plone 5.2 where"plone.restapi>=8.21.2"is a working version. It will not support image scales, but the package will work gracefully without displaying image previews in the search result list.Generic SetupTo automatically enable this package when your add-on is installed, add the following line inside the package'sprofiles/default/metadata.xmldependencieselement:<dependency>profile-kitconcept.solr:default</dependency>Source Code and ContributionsWe welcome contributions tokitconcept.solr.You can create an issue in the issue tracker, or contact a maintainer.Issue TrackerSource CodeDevelopment requirementsPython 3.8 or laterDockerSetupInstall all development dependencies -- including Plone -- and create a new instance using:makeinstallBy default, we use the latest Plone version in the 6.x series.ConfigurationsMost of the development configuration is managed withplone.meta, so avoid manually editing the following files:.editorconfig.flake8.gitignore.pre-commit-config.yamlnews/.changelog_template.jinjapyproject.tomltox.iniIn addition there is Solr related configuration that is outlined in the following chapters.Configuring SolrSolr is configured by a default configuration that can be found in the/solr/etc/folder in this repository. This contains, most notably, theschema.xmlthat defines the indexes for Solr. This package also builds docker images with the default Solr version, set up with this default configuration.If you need to customize the Solr configuration (such as adding new indexes, etc.) then you should copy thesolrfolder into your own project, customize it as you wish, and then build your own docker images (or compile your own Solr server) based on this configuration.A typical use case for why you would want to do this, is if you add new fields to some content types, and you want to render the values for these additional fields in the search results. In this case you want to add the additional fields as indexes to Solr. You probably would not need this, unless you change anything on the result type templates in thekitconcept.volto-solrfront-end package.Configuring the front-end and back-end packagesThe package supports the usage of thekitconcept.volto-solradd-on, and it is designed to be used together with it.The configuration can be specified in a customized way. Without any additional configuration, the package will use the default, which is specified in json format in thekitconcept.solr.interfaces.IKitconceptSolrSettingsregistry.This configuration settings affect the behavior of both thekitconcept.solr(this) back-end package, and thekitconcept.volto-solrfront-end package (a Volto add-on). In addition,kitconcept.volto-solrhas its own Volto add-on configuration which is not explained here, for these options please refer to the documentation of the add-on package.Configuration optionsExplanation for the configuration options:fieldListContains the fields that solr should return. If the search result templates in the volto add-on are modified, and require more fields than in the default list, the fieldsmust explicitly be addedhere.In addition, the same fields must be present in the Solr index - if either the Solr index or the field infieldListis missing, the field value will silently be not returned. No error will be shown.Example value:["UID","Title","Description","Type","effective","start","created","end","path_string","mime_type","phone","email","location","image_scales","image_field"]searchTabsA list of dictionary items representing the facet tabs in the search page.Thelabelfield specifies the label to be shown on the tab in English. It's the front-end package's responsibility to provide translations for this, askitconcept.volto-solrdoes this for the defaults, which can be used as an example.Thefilterfield defines the Solr search condition to the given facet tab. This can be a content type, or in fact any condition understood by Solr, please consult the Solr documentation for more details.Example value:[{"label":"All","filter":"Type(*)"},{"label":"Pages","filter":"Type:(Page)"},{"label":"Events","filter":"Type:(Event)"},{"label":"Images","filter":"Type:(Image)"},{"label":"Files","filter":"Type:(File)"}]Overriding the configuration optionsIf needed, the defaultkitconcept.solr.interfaces.IKitconceptSolrSettingscan be customized in the registry via GenericSetup.Using reindex helpersHelpers for activate and reindex solr are importable from the package.Example for a reindex script that can be called from Makefile:fromkitconcept.solr.reindex_helpersimportactivate_and_reindexfromTesting.makerequestimportmakerequestfromzope.site.hooksimportsetSiteimportsysimporttransactionif__name__=="__main__":app=makerequest(app)# noQA# Set site to Plonesite_id="Plone"portal=app.unrestrictedTraverse(site_id)setSite(portal)activate_and_reindex(portal,clear="--clear"insys.argv)transaction.commit()app._p_jar.sync()Example for an upgrade step that adds thekitconcept.solrpackage, and one that does the solr activation for the first time:fromkitconcept.solr.reindex_helpersimportactivate_and_reindexfromploneimportapiimportlogginglogger=logging.getLogger("your_package_name_here")# We suggest to add two distinct upgrade step for the package installation# and the solr activation, in case of a failure this allows to# identify the problem easier.definstall_kitconcept_solr(context):st=api.portal.get_tool("portal_setup")st.runAllImportStepsFromProfile("kitconcept.solr:default")logger.info("Installed kitconcept.solr")defactivate_and_reindex_solr(context):activate_and_reindex(context)logger.info("Activated and reindexed solr")Update translationsmakei18nFormat codebasemakeformatRun testsTesting of this package is done withpytestandtox.Run all tests with:maketestRun all tests but stop on the first error and open apdbsession:./bin/tox-etest---x--pdbRun only tests that matchTestEndpointEncoding:./bin/tox-etest---kTestEndpointEncodingRun only tests that matchTestEndpointEncoding, but stop on the first error and open apdbsession:./bin/tox-etest---kTestEndpointEncoding-x--pdbCreditsThe development of this add-on has been kindly sponsored byGerman Aerospace Center (DLR)andForschungszentrum Jülich.Developed bykitconceptLicenseThe project is licensed under GPLv2.Changelog1.0.0a4 (2023-10-10)New features:Support Plone 5.2 [@reekitconcept]#171.0.0a3 (2023-08-15)Documentation:Add credits to README @tisto#161.0.0a2 (2023-08-15)Bug fixes:Increase version of collective.solr @reebalazs#141.0.0a1 (2023-08-11)New features:Generateghcr.io/kitconcept/solr@reekitconcept#3Internal:Prepare package for release @ericof#5Revamp solr configuration @reebalazs#12