Skip to content

Commit 6758657

Browse files
Merge pull request #42 from Flowpack/instructions-custom-index-name
!!! TASK: Require manual configuration of autocomplete
2 parents 6418f59 + 096a5cb commit 6758657

3 files changed

Lines changed: 56 additions & 36 deletions

File tree

Configuration/NodeTypes.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,3 @@
44
ui:
55
label: 'Search'
66
icon: 'icon-search'
7-
8-
'Neos.Neos:Document':
9-
superTypes:
10-
'Flowpack.SearchPlugin:SuggestableMixin': true
11-
'Flowpack.SearchPlugin:AutocompletableMixin': true
12-
13-
'Neos.Neos:Shortcut':
14-
superTypes:
15-
'Flowpack.SearchPlugin:SuggestableMixin': false
16-
'Flowpack.SearchPlugin:AutocompletableMixin': false
17-
18-
'Neos.NodeTypes:TitleMixin':
19-
superTypes:
20-
'Flowpack.SearchPlugin:SuggestableMixin': true
21-
'Flowpack.SearchPlugin:AutocompletableMixin': true

Configuration/Settings.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,3 @@ Neos:
1515
Search:
1616
defaultContext:
1717
Flowpack.SearchPlugin.Suggestion: Flowpack\SearchPlugin\EelHelper\SuggestionIndexHelper
18-
19-
Flowpack:
20-
ElasticSearch:
21-
indexes:
22-
default:
23-
typo3cr:
24-
analysis:
25-
filter:
26-
autocompleteFilter:
27-
max_shingle_size: 5
28-
min_shingle_size: 2
29-
type: 'shingle'
30-
analyzer:
31-
autocomplete:
32-
filter: [ 'lowercase', 'autocompleteFilter' ]
33-
char_filter: [ 'html_strip' ]
34-
type: 'custom'
35-
tokenizer: 'standard'

README.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ Inclusion of the routes from this package into your main `Configuration/Routes.y
2121

2222
## Configuration
2323

24+
### Custom index name
25+
26+
It is usually a good idea to specify a custom index name for a project, instead of the default `typo3cr`. That
27+
way no conflicts can arise when multiple projects use the same Elasticsearch server.
28+
29+
To specify a custom index name, the following is needed:
30+
31+
Neos:
32+
ContentRepository:
33+
Search:
34+
elasticSearch:
35+
indexName: acmecom
2436

2537
### Pagination
2638

@@ -47,9 +59,50 @@ Feel free to use the `DocumentSearchResult.html` in the Flowpack.SearchPlugin as
4759
## Search completions and suggestions
4860

4961
The default search form template comes with a `data-autocomplete-source` attribute pointing to the
50-
`SuggestController` of this package. Fed with a `term` parameter via a `GET` request, it returns a
51-
JSON-encoded array of suggestions from Elasticsearch. These are fetched with a term suggester from
52-
the `_all` field, i.e. "the fulltext index".
62+
`SuggestController` of this package.
63+
64+
To use this term suggester, you need to configure the indexing like this, to define a custom
65+
analyzer to be used:
66+
67+
Flowpack:
68+
ElasticSearch:
69+
indexes:
70+
default: # client name used to connect (see Flowpack.ElasticSearch.clients)
71+
acmecom: # your (custom) index name
72+
analysis:
73+
filter:
74+
autocompleteFilter:
75+
max_shingle_size: 5
76+
min_shingle_size: 2
77+
type: 'shingle'
78+
analyzer:
79+
autocomplete:
80+
filter: [ 'lowercase', 'autocompleteFilter' ]
81+
char_filter: [ 'html_strip' ]
82+
type: 'custom'
83+
tokenizer: 'standard'
84+
85+
Then you need to configure the node types to be be included in the suggestion building, this can be
86+
done like this:
87+
88+
'Neos.Neos:Document':
89+
superTypes:
90+
'Flowpack.SearchPlugin:SuggestableMixin': true
91+
'Flowpack.SearchPlugin:AutocompletableMixin': true
92+
93+
'Neos.Neos:Shortcut':
94+
superTypes:
95+
'Flowpack.SearchPlugin:SuggestableMixin': false
96+
'Flowpack.SearchPlugin:AutocompletableMixin': false
97+
98+
'Neos.NodeTypes:TitleMixin':
99+
superTypes:
100+
'Flowpack.SearchPlugin:SuggestableMixin': true
101+
'Flowpack.SearchPlugin:AutocompletableMixin': true
102+
103+
When fed with a `term` parameter via a `GET` request, the `SuggestController` will return a
104+
JSON-encoded array of suggestions from Elasticsearch. They are fetched with a term suggester
105+
from the `_all` field, i.e. "the fulltext index".
53106

54107
These can be used to provide autocompletion on the search input using a JS library of your choice.
55108
In case you need to build the URI to the suggest controller yourself, this is what the form uses:

0 commit comments

Comments
 (0)