Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-plone-5.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
## regardless what I try.

# python cache
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ solr-start-fg: test-compose-project-name ## Start solr in foreground
@echo "Start solr in foreground"
@COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} up

.PHONY: solr-start-and-rebuild
solr-start-and-rebuild: ## Start solr, force rebuild
@echo "Start solr, force rebuild, erases data"
@COMPOSE_PROJECT_NAME=${STACK_NAME} docker compose -f ${SOLR_ONLY_COMPOSE} up -d --build

.PHONY: solr-stop
solr-stop: test-compose-project-name ## Stop solr
@echo "Stop solr"
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ Run only tests that match `TestEndpointEncoding`, but stop on the first error an
./bin/tox -e test -- -k TestEndpointEncoding -x --pdb
```

## Remark about testing and configuration

The package configuration (and the test setup) is quite complex, and especially for testing the highlighting, multiple steps must be present in the configuration. If some of this is missing, the tests will fail.

The highlighting is by default based on the `body_text` index which this package via an indexer. So first, the zcml must be loaded. But also worth noting that the `plone.volto` package must be loaded, if not then the `IBlocks` behavior is not active, and although the index is added, the indexer will not be called. As a consequence, the body_text indexer will not be invoked, leading to potential issues in highlighting.

This is why `volto-solr` is referred from both `metadata.xml` and `dependencies.zcml` in this package. If any of this would be missing, the highlighting would fail.

In an application that uses the `kitconcept.solr` package, loading its zcml and its default profile would be sufficient, because `kitconcept.solr` will pull in the behavior from `plone.volto` and the indexer from `collective.solr`, as needed.

## Credits

The development of this add-on has been kindly sponsored by [German Aerospace Center (DLR)](https://www.dlr.de) and [Forschungszentrum Jülich](https://www.fz-juelich.de).
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
solr:
build:
Expand Down
2 changes: 1 addition & 1 deletion solr/etc/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,4 @@

</fields>

</schema>
</schema>
28 changes: 28 additions & 0 deletions solr/etc/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,26 @@
<int name="rows">10</int>
<str name="df">SearchableText</str>
<str name="wt">xml</str>
<!-- XXX BEGIN -->

<str name="wt">json</str>
<str name="facet">true</str>
<str name="facet.contains.ignoreCase">true</str>

<str name="spellcheck">on</str>
<str name="spellcheck.dictionary">suggestDictionary</str>
<str name="spellcheck.extendedResults">false</str>
<str name="spellcheck.count">4</str>
<str name="spellcheck.alternativeTermCount">2</str>
<str name="spellcheck.maxResultsForSuggest">0</str>
<str name="spellcheck.onlyMorePopular">false</str>
<str name="spellcheck.collate">false</str>

<!-- XXX END -->
</lst>
<arr name="last-components">
<str>suggest</str>
</arr>
</requestHandler>

<requestHandler class="solr.UpdateRequestHandler"
Expand Down Expand Up @@ -260,6 +279,15 @@
<float name="threshold">0.</float>
<str name="buildOnCommit">true</str>
</lst>

<lst name="spellchecker">
<str name="name">default</str>
<str name="field">suggest</str>
<str name="classname">solr.DirectSolrSpellChecker</str>
<str name="distanceMeasure">internal</str>
<float name="accuracy">0.5</float>
</lst>

</searchComponent>

</config>
1 change: 1 addition & 0 deletions src/kitconcept/solr/dependencies.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<include package="plone.app.iterate" />
<include package="plone.api" />
<include package="Products.GenericSetup" />
<include package="plone.volto" />
<include package="collective.solr" />
<include package="plone.restapi" />
<include package="plone.app.caching" />
Expand Down
1 change: 0 additions & 1 deletion src/kitconcept/solr/indexers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,4 @@ def body_text_blocks(obj):
for block_id in blocks_layout.get("items", []):
block = blocks.get(block_id, {})
blocks_text.append(extract_text(block, obj, request))

return " ".join([text.strip() for text in blocks_text if text.strip()])
14 changes: 14 additions & 0 deletions src/kitconcept/solr/profiles/default/catalog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<object name="portal_catalog">

<!-- The body_text index supports highlighting in the block content -->

<index meta_type="KeywordIndex"
name="body_text"
>
<indexed_attr value="body_text" />
</index>

<column value="body_text" />

</object>
3 changes: 2 additions & 1 deletion src/kitconcept/solr/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>1000</version>
<version>1001</version>
<dependencies>
<dependency>profile-plone.volto:default</dependency>
<dependency>profile-collective.solr:default</dependency>
</dependencies>
</metadata>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"image_scales",
"image_field"
],
"highlightingFields": [
{"field": "content", "prop": "highlighting"},
{"field": "title", "prop": "highlighting_title"},
{"field": "description", "prop": "highlighting_description"}
],
"searchTabs": [
{
"label": "All",
Expand Down
Loading