Skip to content

Commit 8f81abc

Browse files
authored
Merge pull request #41 from Flowpack/add-completion-example
TASK: Add example for completion/suggestion result
2 parents 4ed34f2 + bd006ea commit 8f81abc

1 file changed

Lines changed: 43 additions & 2 deletions

File tree

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Flowpack.SearchPlugin
22

33
This plugin is a Search Plugin, to be used together with
4+
45
* [Flowpack.ElasticSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.ElasticSearch.ContentRepositoryAdaptor) or
56
* [Flowpack.SimpleSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.SimpleSearch.ContentRepositoryAdaptor).
67

@@ -43,7 +44,7 @@ Thus you can easily adjust the rendering per type like this for an imaginary `Ac
4344

4445
Feel free to use the `DocumentSearchResult.html` in the Flowpack.SearchPlugin as an example.
4546

46-
## Search suggestions
47+
## Search completions and suggestions
4748

4849
The default search form template comes with a `data-autocomplete-source` attribute pointing to the
4950
`SuggestController` of this package. Fed with a `term` parameter via a `GET` request, it returns a
@@ -53,7 +54,47 @@ the `_all` field, i.e. "the fulltext index".
5354
These can be used to provide autocompletion on the search input using a JS library of your choice.
5455
In case you need to build the URI to the suggest controller yourself, this is what the form uses:
5556

56-
{f:uri.action(action: 'index', controller: 'Suggest', package: 'Flowpack.SearchPlugin', format: 'json', absolute: 1)}
57+
{f:uri.action(action: 'index', controller: 'Suggest', package: 'Flowpack.SearchPlugin', format: 'json', absolute: 1, arguments: {contextNodeIdentifier: node.identifier, dimensionCombination: dimensionCombination})}
58+
59+
The returned JSON looks like this (with a `term` of "content" after indexing the Neos demo site):
60+
61+
{
62+
"completions": [
63+
"content",
64+
"content element",
65+
"content in",
66+
"content in neos",
67+
"content in neos because",
68+
"content in neos because you",
69+
"content repository"
70+
],
71+
"suggestions": [
72+
{
73+
"text": "995c9174-ddd6-4d5c-cfc0-1ffc82184677",
74+
"score": 20,
75+
"payload": {
76+
"nodeIdentifier": "d17caff2-f50c-d30b-b735-9b9216de02e9"
77+
}
78+
},
79+
{
80+
"text": "a66ec7db-3459-b67b-7bcb-16e2508a89f0",
81+
"score": 20,
82+
"payload": {
83+
"nodeIdentifier": "fd283257-9b12-8412-f922-6643ac818294"
84+
}
85+
},
86+
{
87+
"text": "a3474e1d-dd60-4a84-82b1-18d2f21891a3",
88+
"score": 20,
89+
"payload": {
90+
"nodeIdentifier": "7eee2ee6-2a4e-5240-3674-2fb84a51900b"
91+
}
92+
}
93+
]
94+
}
95+
96+
The `completions` can be used to suggest search terms to the user. The `suggestions` contains
97+
"top search results" for the given term, the document they refer to is given in the `payload`.
5798

5899
## AJAX search
59100

0 commit comments

Comments
 (0)