Rework the Search class and provide a search service
This is a rough concept:
- SearchInterface
- index(DocumentInterface $doc)
- indexLazy(DocumentInterface $doc)
- triggerLazyIndex()
- search(QueryInterface $query)
- etc.
- DocumentInterface
- getUrl()
- getContent()
- getProtected()
- etc.
Every Controller or Page type decides on its own whether to index something or not and does that by calling either $this->search->index() for immediate indexing or $this->search->indexLazy() for adding the content to the service and do a bulk insert when triggerLazyIndex() is called.
The AddToSearchIndexListener executes $this->search->triggerLazyIndex().
Advantages to the current implementation:
- We get rid of one more "legacy" class (
Search). - The Search service can easily replaced by Elasticsearch and Co. All they need to do is implement our
SearchInterface. - It's possible to add content by different content providers for the same url.
- In theory, rebuilding the index can be sub requests instead of real requests.
Also, drop the current getSearchablePages() behaviour in favour of a simple web crawler (see contao/core#6942). Note that it must update on a regular basis using a cronjob behaviour as well as manually in the back end somehow.
+1
+1
This is a long running task, which will eventually result in the https://github.com/contao/search library.