core-bundle icon indicating copy to clipboard operation
core-bundle copied to clipboard

Rework the Search class and provide a search service

Open Toflar opened this issue 10 years ago • 4 comments

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.

Toflar avatar May 04 '15 09:05 Toflar

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.

Toflar avatar May 21 '15 15:05 Toflar

+1

Metis77 avatar Jun 07 '17 13:06 Metis77

+1

HolyMacarony avatar Mar 28 '19 01:03 HolyMacarony

This is a long running task, which will eventually result in the https://github.com/contao/search library.

leofeyer avatar Jun 11 '20 15:06 leofeyer