Skip to content

Commit d1e1d13

Browse files
authored
TASK: Add example for completion/suggestion result
1 parent 57e128d commit d1e1d13

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

README.md

Lines changed: 42 additions & 1 deletion
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
@@ -55,6 +56,46 @@ In case you need to build the URI to the suggest controller yourself, this is wh
5556

5657
{f:uri.action(action: 'index', controller: 'Suggest', package: 'Flowpack.SearchPlugin', format: 'json', absolute: 1)}
5758

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`.
98+
5899
## AJAX search
59100

60101
The plugin comes with a controller that can be reached like this per default, using `GET`:

0 commit comments

Comments
 (0)