Global search: Difference between revisions
Eric Merrill (talk | contribs) (Add information about encrypting Solr connection) |
Eric Merrill (talk | contribs) (Update SSL info) |
||
Line 197: | Line 197: | ||
# You will need a separate key file and cacert file, both in pem format, located on your server Moodle, and readable by the PHP process. | # You will need a separate key file and cacert file, both in pem format, located on your server Moodle, and readable by the PHP process. | ||
# | # Go to ''Site administration > Plugins > Search > Solr'' | ||
# | # Set '''Secure mode''' to Yes | ||
# | # '''SSL certificate''' to /path/to/certs/solr-ssl.cacert.pem | ||
# | # '''SSL key''' to /path/to/certs/solr-ssl.key.pem | ||
# | # '''SSL key Password''' to The password used to lock the SSL Key | ||
# | # '''SSL CA certificates name''' to /path/to/certs/solr-ssl.cacert.pem | ||
# Save | # Save | ||
# On the search management page it | # On the search management page it should indicate it can connect to Solr. | ||
= Indexing = | = Indexing = |
Revision as of 13:47, 12 May 2016
Installation
To use Solr as Moodle's search engine you need the PHP Solr extension and a Solr server.
PHP Solr extension
You need PHP Solr extension installed. You can download the official latest versions from [1](http://pecl.php.net/package/solr) The minimum required version is PECL Solr 2.1 for PHP 5 branch and PECL Solr 2.4 for PHP 7 branch.
Basic installation steps (using apache web server):
Linux (Debian/Ubuntu)
sudo apt-get install libpcre3-dev libxml2-dev libcurl4-openssl-dev sudo apt-get install php5-dev sudo apt-get install php-pear sudo pecl install solr sudo service apache2 restart sudo sh -c "echo 'extension=solr.so' > /etc/php5/apache2/conf.d/solr.ini" sudo sh -c "echo 'extension=solr.so' > /etc/php5/cli/conf.d/solr.ini"
OSX using macports
sudo port install apache-solr4 sudo port install php54-solr
OSX using homebrew
brew install homebrew/php/php56-solr
Windows
Install the pecl package as usual. Sorry it has not been tested yet.
Solr server
Moodle 3.1 supports Solr server from 4.0 onwards, although you can only use the Solr schema setup script that we provide with Moodle from Solr 5. The latest Solr 5 available version is the recommended one, same applicable to Solr 6 once it is released.
The following example snippet (feel free to copy & paste into a .sh script with execution permissions) will download Solr 5.4.1 (replace it with latest 5.x) in the current directory, start the solr server and create an index in it named moodle to add moodle data to it.
#!/bin/bash set -e SOLRVERSION=5.4.1 SOLRNAME=solr-$SOLRVERSION SOLRTAR=$SOLRNAME'.tgz' INDEXNAME=moodle if [ -d $SOLRNAME ]; then echo "Error: Directory $SOLRNAME already exists, remove it before starting the setup again." exit 1 fi if [ ! -f $SOLRTAR ]; then wget http://apache.mirror.digitalpacific.com.au/lucene/solr/$SOLRVERSION/$SOLRTAR fi tar -xvzf $SOLRTAR cd $SOLRNAME bin/solr start bin/solr create -c $INDEXNAME # After setting it up and creating the index use: # - "/yourdirectory/solrdir/bin/solr start" from CLI to start the server # - "/yourdirectory/solrdir/bin/solr stop" from CLI to stop the server.
Setup
- Go to Site administration -> Plugins -> Search -> Manage global search
- Follow Search setup steps to complete the setup process. Basically you have to:
- Enable global search
- Set Solr as search engine and tick all search areas checkboxes
- Go to Site administration -> Plugins -> Search -> Solr and set Host name to localhost, Port to 8983 and Index name to 'moodle' (the name of the index in Solr)
Solr 4 schema setup
As mentioned above you can not use the schema setup script when using a Solr 4 server. Here you can find the field types description below in case you really want to use Solr 4.x branch.
Extracted from search/classes/document.php
Field name | Field type | Stored | Indexed | Query field |
---|---|---|---|---|
id | org.apache.solr.schema.StrField | true | false | false |
itemid | org.apache.solr.schema.TrieIntField | true | true | false |
title | org.apache.solr.schema.TextField | true | true | true |
content | org.apache.solr.schema.TextField | true | true | true |
contextid | org.apache.solr.schema.TrieIntField | true | true | false |
areaid | org.apache.solr.schema.StrField | true | true | false |
type | org.apache.solr.schema.TrieIntField | true | true | false |
courseid | org.apache.solr.schema.TrieIntField | true | true | false |
owneruserid | org.apache.solr.schema.TrieIntField | true | true | false |
modified | org.apache.solr.schema.TrieDateField | true | true | false |
userid | org.apache.solr.schema.TrieIntField | true | true | false |
description1 | org.apache.solr.schema.TextField | true | true | true |
description2 | org.apache.solr.schema.TextField | true | true | true |
solr_filegroupingid | org.apache.solr.schema.StrField | true | true | false |
solr_fileid | org.apache.solr.schema.StrField | true | true | false |
solr_filecontenthash | org.apache.solr.schema.StrField | true | true | false |
solr_fileindexstatus | org.apache.solr.schema.TrieIntField | true | true | false |
solr_filecontent | org.apache.solr.schema.TextField | false | true | true |
SSL Setup
If you are using Solr with SSL encryption, you will need to configure Moodle as such.
- You will need a separate key file and cacert file, both in pem format, located on your server Moodle, and readable by the PHP process.
- Go to Site administration > Plugins > Search > Solr
- Set Secure mode to Yes
- SSL certificate to /path/to/certs/solr-ssl.cacert.pem
- SSL key to /path/to/certs/solr-ssl.key.pem
- SSL key Password to The password used to lock the SSL Key
- SSL CA certificates name to /path/to/certs/solr-ssl.cacert.pem
- Save
- On the search management page it should indicate it can connect to Solr.
Indexing
Once global search is enabled a new task will be running through cron, although you can force documents indexing by:
- Going to Reports -> Global search info
- Tick Index all site contents and press Execute
or
- Executing the following task from CLI
php admin/tool/task/cli/schedule_task.php --execute="\\core\\task\\search_index_task"
Querying
- Hover the search icon in the navigation bar, type your query and press Enter
or
- Add Global search block somewhere
- Type your query and press Search