Download the PHP package punktde/elastic-nodesearchservice without Composer
On this page you can find all versions of the php package punktde/elastic-nodesearchservice. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download punktde/elastic-nodesearchservice
More information about punktde/elastic-nodesearchservice
Files in punktde/elastic-nodesearchservice
Package elastic-nodesearchservice
Short Description Implementation of the Neos NodeSearchServiceInterface using the Elasticsearch index
License MIT
Informations about the package elastic-nodesearchservice
PunktDe.Elastic.NodeSearchService
This is an implementation of the Neos NodeSearchService using the Elasticsearch index of the content repository. This vastly reduces the query time for Search-As-You-Type fields in the backend if you have lots of nodes in your project. Additionally it is highly customizable in order to get the best search experience for the project.
Multiple search strategies can be defined which are then selected according to the SearchNodeType, StartingPoint and the term. With this feature you are able to sort news documents returned in a reference selector by publish date while other documents are sorted alphabetically.
Note: While the original database search does a like search in all properties of the document, the default strategy of this package only does a prefix search in the title field. Replace it with the search strategy that fit your needs.
The following example shows a reference selector for news articles with 23 000 Documents.
Installation
The installation is done with composer:
composer require punktde/elastic-nodesearchservice
Compatibility to Flowpack.ElasticSearch.ContentRepositoryAdaptor:
Elastic.NodeSearchService | ElasticSearch.ContentRepositoryAdaptor |
---|---|
1 | 5.x, 6.x |
2 | 7.x |
Configuration
Example
This example uses a multi_match prefix query to search in the punktde_node_search
field indexed for documents.
PunktDe:
Elastic:
NodeSearchService:
logRequests: true
searchStrategies:
position: end
titlePrefix:
condition: '${Array.indexOf(searchNodeTypes, "Neos.Neos:Document")}'
request:
query:
bool:
filter:
bool:
minimum_should_match: 1
should:
- multi_match:
query: ARGUMENT_TERM
type: bool_prefix
fields: ['punktde_node_search', 'punktde_node_search._2gram', 'punktde_node_search._3gram']
must:
- terms:
neos_type_and_supertypes: ARGUMENT_SEARCHNODETYPES
- term:
neos_parent_path : ARGUMENT_STARTINGPOINT
must_not:
- term:
neos_hidden: true
_source:
- __path
size: 20
The position
determines in which order the strategy conditions are evaluated.
The condition
is an Eel query, which can be parametrized by the following values. It is used to determine the search strategy to be used.
If no search strategy could be found, it falls back to database search.
ParameterName | Description |
---|---|
string term |
The search term |
array searchNodeTypes |
Array of the search nodetypes |
Context context |
The given node context |
NodeInterface startingPoint |
The defined starting point |
These following parameters can be used in the search request to parametrice the query:
ParameterName | Description |
---|---|
ARGUMENT_SEARCHNODETYPES | Array_Values of the filter NodeTypes. |
ARGUMENT_TERM | The Searchterm |
ARGUMENT_STARTINGPOINT | The startingPoint path |
Tip: Use a marker nodeType to determine the best search strategy
Sometimes reference editors for certain nodeTypes profit from custom search strategies. Eg. Only list document nodes that are visible and have a certain property set. We have limited options to determine a search strategy, thus we use the following trick:
-
Define a marker nodeType
-
Use this marker nodeType in your referenceEditor
- Use this nodeType within the search strategy condition
All versions of elastic-nodesearchservice with dependencies
flowpack/elasticsearch-contentrepositoryadaptor Version ^7.0 || ^8.0 || dev-master
neos/neos Version ^5.0 || ^7.0 || ^8.0