Setup the Solr Extension¶
Requirements¶
Please check if you are meeeting the needed requirements:
- PHP version
- Apache Solr Server version
- Solr Schema version
- Minimum TYPO3 version
- Scheduler is installed and running
More details can be found here: Supported Solr versions
1. Install the TYPO3 Extension¶
- Install the extension using the Extension Manager
- Install the required additional extensions (pagebrowse, suggested: devlog)
2. Add the static TS (typoscript) to your typoscript template¶
- Include the static TypoScript from the solr extension.
- Set config.index_enable = 1 inside your TS template
By default the the install script will have installed the Solr server so that it can be reached at http://localhost:8080/solr/, it will have a default english core set up, too which will be at http://localhost:8080/solr/core_en/. The default TypoScript configuration will also point to the english core so that you should be ready to go. If you installed Solr differently you may have to adjust the conenction parameters in plugin.tx_solr.solr.*.
3. Set the "Use as Root Page" attribute to the your site's root page¶
Find the root of your site, edit page properties and set the checkbox for the "Use as Root Page" flag on the "Behaviour" tab.
4. Add a domain record¶
On your site's root page add a domain record with your installation's domain. You also need a domain record for local test installations, in those cases you probably need to set the domain to "localhost".
You can have multiple domain records, but the first active one is the one the extension will use during page indexing.
5. Initialize the Solr connections¶
In the clear cache menu you can find an entry "Initialize Solr connections". By clicking this entry the solr extension will look for your root pages and the system languages. Each combination will be tried out and if a configured Solr connection is found it will be saved to TYPO3's registry.
6. Check the status report in the reports module¶
The reports module has a Solr section in the status report. It will complain about different aspects and give hints to solve them. Most of the time the reasons can be found in different aspects like:
- The Solr Server can not be reached. Firewall. DNS. PHP Modules. SELinux and the likes can be reasons for this
- You are using the wrong schema.xml that is not supported to work with the installed extension.
- ...
If everything is ok, it should look like this:
See more about trouble-shooting here.
7. Initialize the Index Queue¶
The solr extension uses the Index Queue to index your content. It is pre-configured to index pages and an example configuration for EXT:tt_news is provided, too. To index pages you have to initialize the Index Queue. Got to the "Search" module in Admin Tools and click "Initialize Index Queue".
By clicking the initialize Button the extension will collect all the pages in your site and add them to the Index Queue. The Index Queue worker task will then index these pages. Whenever an editor changes a content element or a page property the Record Monitor will mark the changed page in the Index Queue to be indexed again.
8. Set up the Index Queue worker task¶
As already mentioned the solr extension uses the Index Queue and the Index Queue Worker task to index your content. Together the Index Queue, the Index Queue Worker Task, the Record Monitor, and the Garbage Collector are meant to work like an auto-pilot. To make this work you need to set up the Index Queue Worker task in the scheduler.
After having set up the Index Queue Worker task, let it run until everything is indexed.
Now head back to the Search admin module and commit your indexed documents.
Solr keeps new documents in a buffer to not write the index with each new document. The configuration files coming with the solr extension will configure Solr to commit automatically after one hour or after each 100 new documents, whatever happens first. So usually you do not have to care about it. For the purpose of this tutorial we do not want to wait an hour of course and so will trigger the commit manually.
9. Add a search plugin¶
Simply create a page and add a search plugin. Either choose a "General Plugin" content element and then select the "Search: Form, Results, Additonal Components" plugin or, even easier simply use the "Search Form" content element, it is the same as going through the plugin content element.
This is it for a basic setup, you should now be able to search your website.