Hey, I am creating a global search for a website. I am using SimpleSearch and am quite happy with this solution.
After a few easy configurations, I am now stuck.
I can search for page titles with this code, but not for content. Instead, the search spits out results that have a matching result neither in the title nor in the content, but in the database field “persistence_object_identifier”.
For example, a search just for the letter “A” gives me this result:
Home
9ee21871-d5e0-47fb-ac80-58e1ded4df7c
Über uns
580f8e94-a4d2-4e03-8580-4a6bb056e771
What I want is:
The search will ignore this database field and look for the content instead.
I would also be satisfied if the search would read the description of the page if that makes it easier.
I hope someone has experience with SimpleSearch and can help me.
Best regards
Julian
PS: Is any documentation of SimpleSearch out there?
#Root.fusion
prototype(Flowpack.SimpleSearch.ContentRepositoryAdaptor:Search) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://WG.Basesite/Private/Fusion/PluginOverwrites/Flowpack.SimpleSearch.ContentRepositoryAdaptor/Resources/Private/Templates/NodeTypes/Search.html'
searchResults = ${Search.query(site).nodeType('Neos.Neos:Document').log().fulltext(request.arguments.search.word).execute()}
searchWord = ${request.arguments.search.word}
searchQuery = ${this.searchWord ? Search.query(site).nodeType('WG.BaseSite:Document.AbstractPage').log().fulltext(request.arguments.search.word + '*') : null}
searchResultContent = ${Search.query(searchResult).nodeType('Neos.Neos:Content').fulltextMatchResult(request.arguments.search.word + '*')}
configuration = Neos.Fusion:DataStructure {
itemsPerPage = 5
insertAbove = false
insertBelow = true
maximumNumberOfLinks = 3
}
@cache {
mode = 'uncached'
context {
1 = 'site'
2 = 'node'
}
}
}
#Search.html
{namespace neos=Neos\Neos\ViewHelpers}
{namespace fusion=Neos\Fusion\ViewHelpers}
{namespace search=Neos\ContentRepository\Search\ViewHelpers}
<div class="flowpack-simplesearch-search">
<form method="POST">
<input id="searchInput" name="search[word]" value="{searchWord}" />
<input type="hidden" name="--neos-contentrepository-viewhelpers-widget-paginateviewhelper[currentPage]"
value="" />
<button type="submit"></button>
</form>
<!-- <hr/> -->
<f:if condition="{searchWord}">
<div id="searchResults" class="search-results">
<f:if condition="{searchQuery}">
<dl>
<search:widget.paginate query="{searchQuery}" as="paginatedNodes" configuration="{configuration}">
<f:for each="{paginatedNodes}" as="searchResult">
<dt><neos:link.node node="{searchResult}">{searchResult.fullLabel}</neos:link.node></dt>
<dd>
<fusion:render path="searchResultContent" context="{searchResult: searchResult}" />
</dd>
</f:for>
</search:widget.paginate>
</dl>
</f:if>
</div>
</f:if>
</div>